pds_core: Add PLDM firmware update and host backed memory support
Subsystems (4)
v12 cover pds_core: Add PLDM firmware update and host backed memory support
This series adds PLDM-based firmware update support to the pds_core driver. PLDM (Platform Level Data Model) is a DMTF standard for firmware management that provides a vendor-neutral interface for firmware updates.
The implementation uses the kernel's pldmfw library for package parsing and component matching. Users can update entire firmware packages or individual components via devlink flash. Component information is displayed via devlink info, showing firmware versions and update status for each component.
The series also adds host backed memory support, allowing firmware to request memory pages from the host for its operations.
Changes since v11:
- Patch 3 (PLDM firmware update): move the pdsc_fw_components_invalidate() prototype from patch 4 (component info) into this patch, which is where the function is defined and first called. This fixes a per-commit -Wmissing-prototypes warning under clang W=1 flagged by the netdev CI. No functional change.
- Link to v11: https://patch.msgid.link/[email protected]
Changes since v10:
- v10 did not reach the list.
- Patch 3 (PLDM firmware update): revert to matching the requested component by type against the components in the package (as in v8 and earlier). v10 filtered the package by a single device-side identifier via PLDMFW_UPDATE_MODE_SINGLE_COMPONENT, but the same component type can have different identifiers in the standard vs gold firmware packages, so per-component update could fail with -ENOENT. Also reject a per-component update when the requested component is not present in the package.
Changes since v9:
- Patch 3 (PLDM firmware update):
- Fix a v9 rebase error that reintroduced an -EOPNOTSUPP guard in pdsc_dl_flash_update(), which rejected all per-component flash requests and made per-component update unreachable.
- Implement per-component update using the pldmfw PLDMFW_UPDATE_MODE_SINGLE_COMPONENT mode and component_identifier instead of a driver-side component-name filter. The name filter silently reported success when the requested component was absent from the package (nothing was flashed); the framework mode rejects that case instead.
- Link to v9: https://patch.msgid.link/[email protected]
Changes since v8:
- Rebase onto net-next after latest net -> net-next merge
- Link to v8: https://patch.msgid.link/[email protected]
Changes since v7:
- Patch 2 (identity version 2): log "Cannot identify device" from pdsc_identify() (the final outcome) instead of pdsc_identify_ver(), so the benign v2->v1 identity fallback stays quiet.
- Patch 3 (PLDM firmware update):
- Skip a component whenever send_component_tbl reports response 1, not only PREREQS_NOT_MET, so components the device reports at an identical or lower version are skipped at the component-table stage and reported as "Skipped" via devlink.
- Initialize the deferred DMA list/lock in pdsc_probe() instead of pdsc_init_pf(); pdsc_deferred_dma_free() runs on the common PF/VF remove path, so on a VF it spliced an uninitialized list head.
Changes since v6:
- Patch 3 (PLDM firmware update):
- Add config space read after pci_clear_master() in teardown to ensure in-flight DMA has completed before freeing deferred buffers
- Use list_splice_init() to detach deferred DMA list under lock, then iterate and free without holding the lock
- Add NL_SET_ERR_MSG_MOD calls to PLDM error paths for better error reporting via netlink extack
- Use PDSC_FW_COMPONENT_FULL_NAME_BUFLEN macro instead of ad-hoc buffer size in pdsc_flash_component()
- Simplify finalize_update loop condition to if (err != -EAGAIN)
- Reject devlink flash with component parameter when firmware doesn't support PLDM (returns -EOPNOTSUPP). This depends on a fix submitted via net: https://lore.kernel.org/netdev/[email protected]
- Update documentation clarifying fw.gold is not a flash target
- Patch 4 (component info):
- Use READ_ONCE/WRITE_ONCE pairing for num_components to get a consistent snapshot; avoids iterating zero times with no fallback when recovery path invalidates the cache concurrently
Changes since v5:
- Patch 3: Changed "fw.suc.mainfw" to "fw.suc" for System Unit Controller firmware to be consistent with the "fw.mainfw" to "fw" change in v4
- Fixed bugs identified by sashiko:
Patch 3 (PLDM firmware update):
- Remove stray kdoc fragment in pds_core_send_component_op enum
Patch 4 (component info):
- Fix fallback to dev_info.fw_version when pdsc_get_component_info() succeeds but returns zero components
Patch 5 (host backed memory):
- Expand PDSC_HOST_MEM_MAX_CONTIG comment to clarify why PAGE_SIZE << MAX_PAGE_ORDER is not used
Changes since v4 (sashiko review, Simon Horman):
- Invalidate cached component info in recovery path to ensure stale versions are not reported after firmware changes
- Fix v1 error handling: propagate errors from pdsc_dl_fw_list_info_get() instead of masking them
- Fix v2 error handling: fall back to dev_info.fw_version only when pdsc_get_component_info() fails; propagate devlink errors so partial replies are discarded
- Clean up max_fw_slots comment to clarify it contains component count
Changes since v3:
- Changed "fw.mainfw" to just "fw" for main firmware (Jakub Kicinski). Gold slot main firmware is reported as "fw.gold".
- Removed redundant memset before alloc_pages (Paolo Abeni)
- Changed dev_err to dev_warn for alloc_pages failure (Paolo Abeni)
- Only report dev_info.fw_version for identity version 1 (version 2+ reports firmware via PLDM component info)
- Fixed checkpatch alignment issue by extracting pdsc_dl_info_get_v1() helper function
Changes since v2:
- Use driver-defined component names instead of passing through firmware names (Jakub Kicinski). Added component_type enum that firmware populates, driver maps to stable names like fw, fw.gold, fw.bootloader. Added documentation of firmware version names to pds_core.rst.
- Fixed bugs identified by sashiko:
Patch 2 (identity version 2):
- Fix comment using wrong macro names (IDENTIFY vs IDENTITY)
Patch 3 (PLDM firmware update):
- DMA-after-free on EAGAIN/ETIMEDOUT: when a command times out or returns busy, firmware may still be accessing the DMA buffer; defer freeing until a subsequent command succeeds
- Use dev_warn_once for incompatible firmware version (ver==0)
- Clear component cache after flash to show updated versions
Patch 4 (component info):
- Fix min_t(u8) truncation of max_fw_slots (u16) to min_t(u16)
- Fix F_FIXED early return skipping F_RUNNING flag check
- Don't fail devlink info if component query fails; use dev_warn_once and continue to report generic fields (fw, asic.id, serial_number)
Patch 5 (host backed memory):
- Switch from adminq to devcmd; fixes both workqueue self-deadlock during recovery (adminq completion runs on same wq as health_thread) and health_work re-queued after cancel (adminq timeout re-queues work)
- Remove MEM_DEL from teardown path; fixes both MEM_DEL sent twice for same tag and num_host_mem_reqs ambiguous semantics (now only tracks pages to free). pci_clear_master guarantees DMA quiescence.
- Fix PDSC_HOST_MEM_MAX_CONTIG to 4MB constant (was arch-dependent)
- Not fixed: pdsc_host_mem_add() failure ignored; partial host memory is acceptable and firmware handles fewer regions than requested
Patch 6 (debugfs):
- Move pdsc_debugfs_del_host_mem() before pdsc_host_mem_free() to fix use-after-free race with debugfs readers
- Use %u for unsigned types and %pad for dma_addr_t
- Remove "file exists" check (now dead code since teardown removes file)
Note: The following fix was submitted separately via net:
- DMA in flight during teardown (call pci_clear_master before freeing host memory):
https://lore.kernel.org/all/[email protected]/
Changes since v1:
- Removed redefinition of __counted_by kernel primitive (Jakub Kicinski)
- Fixed kdoc warnings in pds_core_if.h
- Fixed checkpatch warnings
- Fixed bugs identified by sashiko:
Patch 2 (identity version 2):
- Zero data region before firmware commands
- Suppress expected error message during identify probe
Patch 3 (PLDM firmware update):
- Memory leak in pdsc_send_component_image() error path
- Memory leak in pdsc_flash_component() error path
- Missing devcmd_lock in pdsc_devcmd_finalize_update()
- Fixed dma_mapping_error() return value handling (returns boolean, not error code)
- Skip logic for components with index > 255
Patch 4 (component info):
- Added generic fw version display for all identity versions
- Handle components with both RUNNING and STARTUP flags
Patch 5 (host backed memory):
- Race between pdsc_remove and health thread (use-after-free)
- Set missing index field in MEM_QUERY command
- Host memory allocation size and zeroing
- Don't free host memory on MEM_ADD timeout (firmware may still be using it)
Patch 6 (debugfs):
- Fix dentry reference leak in debugfs_lookup (missing dput)
- Improvements:
- Cache component info to avoid repeated firmware queries (patch 4)
Note: The following fix for an existing bug was submitted separately via net:
- Timeout error overwritten with stale status:
https://lore.kernel.org/netdev/[email protected]/
---
---
---
Changes in v12:
- Patch 3 (PLDM firmware update): move the pdsc_fw_components_invalidate() prototype from patch 4 into patch 3 where the function is defined and first called, fixing a per-commit -Wmissing-prototypes warning under clang W=1. No functional change.
- Link to v11: https://patch.msgid.link/[email protected]
---
Brett Creeley (4):
pds_core: add support for quiet devcmd failures
pds_core: add support for identity version 2
pds_core: add PLDM firmware update support via devlink flash
pds_core: add PLDM component info display
Nikhil P. Rao (2):
pds_core: add host backed memory support for firmware
pds_core: add debugfs support for host backed memory
.../device_drivers/ethernet/amd/pds_core.rst | 89 +++ drivers/net/ethernet/amd/Kconfig | 1 + drivers/net/ethernet/amd/pds_core/core.c | 173 +++++ drivers/net/ethernet/amd/pds_core/core.h | 54 +- drivers/net/ethernet/amd/pds_core/debugfs.c | 45 ++ drivers/net/ethernet/amd/pds_core/dev.c | 144 +++- drivers/net/ethernet/amd/pds_core/devlink.c | 149 +++- drivers/net/ethernet/amd/pds_core/fw.c | 796 ++++++++++++++++++++- drivers/net/ethernet/amd/pds_core/main.c | 7 + include/linux/pds/pds_core_if.h | 469 ++++++++++++ 10 files changed, 1899 insertions(+), 28 deletions(-)
---
base-commit: 89d8006259b81dd25c962f6cc8d7ab268d6ea426
change-id: 20260721-upstream_v8-9329be5465a6
Best regards,
Signature · 1 line
Nikhil P. Rao <[email protected]>
PATCH v12 1/6 pds_core: add support for quiet devcmd failures
From: Brett Creeley <[email protected]>
Currently there aren't any use-cases that require special handling on whether or not to print devcmd failures. Specifically non-generic failures, i.e. not supported failures. Add support to allow these messages to be suppressed. This will be used when adding support to negotiate PDS_CORE_IDENTITY_VERSION_2.
--- drivers/net/ethernet/amd/pds_core/dev.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
drivers/net/ethernet/amd/pds_core/dev.c +13 -5
@@ -126,7 +126,8 @@ static const char *pdsc_devcmd_str(int opcode) } } -static int pdsc_devcmd_wait (struct pdsc *pdsc,u8 opcode,int max_seconds) +static int __pdsc_devcmd_wait (struct pdsc *pdsc,u8 opcode,int max_seconds, +const bool do_msg) {struct device *dev = pdsc->dev;unsigned long start_time;
@@ -179,7 +180,7 @@ static int pdsc_devcmd_wait(struct pdsc *pdsc, u8 opcode, int max_seconds) status =pdsc_devcmd_status (pdsc); err =pdsc_err_to_errno (status); -if (err && err != -EAGAIN ) +if (do_msg && err && err != -EAGAIN )dev_err (dev,"DEVCMD %d %s failed, status=%d err %d %pe\n" , opcode,pdsc_devcmd_str (opcode), status, err,ERR_PTR (err));
@@ -187,8 +188,9 @@ static int pdsc_devcmd_wait(struct pdsc *pdsc, u8 opcode, int max_seconds)return err; } -int pdsc_devcmd_locked (struct pdsc *pdsc,union pds_core_dev_cmd *cmd, -union pds_core_dev_comp *comp,int max_seconds) +static int __pdsc_devcmd_locked (struct pdsc *pdsc,union pds_core_dev_cmd *cmd, +union pds_core_dev_comp *comp,int max_seconds, +const bool do_msg) {int err;
@@ -197,7 +199,7 @@ int pdsc_devcmd_locked(struct pdsc *pdsc, union pds_core_dev_cmd *cmd,memcpy_toio (&pdsc->cmd_regs->cmd, cmd,sizeof (*cmd));pdsc_devcmd_dbell (pdsc); - err =pdsc_devcmd_wait (pdsc, cmd->opcode, max_seconds); + err =__pdsc_devcmd_wait (pdsc, cmd->opcode, max_seconds, do_msg);if ((err == -ENXIO || err == -ETIMEDOUT ) && pdsc->wq)queue_work (pdsc->wq, &pdsc->health_work);
@@ -207,6 +209,12 @@ int pdsc_devcmd_locked(struct pdsc *pdsc, union pds_core_dev_cmd *cmd,return err; } +int pdsc_devcmd_locked (struct pdsc *pdsc,union pds_core_dev_cmd *cmd, +union pds_core_dev_comp *comp,int max_seconds) +{ +return __pdsc_devcmd_locked (pdsc, cmd, comp, max_seconds, true); +} +int pdsc_devcmd (struct pdsc *pdsc,union pds_core_dev_cmd *cmd,union pds_core_dev_comp *comp,int max_seconds) {
Signature · 1 line
2.43.0
PATCH v12 2/6 pds_core: add support for identity version 2
In reply to Nikhil P. RaoFrom: Brett Creeley <[email protected]>
Add a new capabilities field in struct pds_core_dev_identity, which requires bumping the identity version to 2, i.e. PDS_CORE_IDENTITY_VERSION_2. If version 2 negotiation fails, then quietly fall back to version 1. If version 1 negotiation fails, then driver load will fail.
Another patch in the series will make use of the capabilities field.
--- drivers/net/ethernet/amd/pds_core/dev.c | 44 ++++++++++++++++++++++++++------- include/linux/pds/pds_core_if.h | 4 +++ 2 files changed, 39 insertions(+), 9 deletions(-)
drivers/net/ethernet/amd/pds_core/dev.c +35 -9
@@ -250,15 +250,17 @@ int pdsc_devcmd_reset(struct pdsc *pdsc)return pdsc_devcmd (pdsc, &cmd, &comp, pdsc->devcmd_timeout); } -static int pdsc_devcmd_identify_locked (struct pdsc *pdsc) +static int pdsc_devcmd_identify_locked (struct pdsc *pdsc,u8 drv_ident_ver, +bool do_msg) {union pds_core_dev_comp comp = {};union pds_core_dev_cmd cmd = { .identify.opcode =PDS_CORE_CMD_IDENTIFY , - .identify.ver =PDS_CORE_IDENTITY_VERSION_1 , + .identify.ver = drv_ident_ver, }; -return pdsc_devcmd_locked (pdsc, &cmd, &comp, pdsc->devcmd_timeout); +return __pdsc_devcmd_locked (pdsc, &cmd, &comp, pdsc->devcmd_timeout, + do_msg); }static void pdsc_init_devinfo (struct pdsc *pdsc)
@@ -281,8 +283,9 @@ static void pdsc_init_devinfo(struct pdsc *pdsc)dev_dbg (pdsc->dev,"fw_version %s\n" , pdsc->dev_info.fw_version); } -static int pdsc_identify (struct pdsc *pdsc) +static int pdsc_identify_ver (struct pdsc *pdsc,u8 drv_ident_ver) { +bool do_msg = drv_ident_ver ==PDS_CORE_IDENTITY_VERSION_1 ;struct pds_core_drv_identity drv = {};size_t sz;int err;
@@ -305,19 +308,22 @@ static int pdsc_identify(struct pdsc *pdsc) sz =min_t (size_t,sizeof (drv),sizeof (pdsc->cmd_regs->data));memcpy_toio (&pdsc->cmd_regs->data, &drv, sz); - err =pdsc_devcmd_identify_locked (pdsc); + err =pdsc_devcmd_identify_locked (pdsc, drv_ident_ver, do_msg);if (!err) { sz =min_t (size_t,sizeof (pdsc->dev_ident),sizeof (pdsc->cmd_regs->data));memcpy_fromio (&pdsc->dev_ident, &pdsc->cmd_regs->data, sz); + +/* V1 firmware doesn't set capabilities, so the field may +* contain garbage from the outgoing driver identity. +*/ +if (pdsc->dev_ident.version <PDS_CORE_IDENTITY_VERSION_2 ) + pdsc->dev_ident.capabilities =0 ; }mutex_unlock (&pdsc->devcmd_lock); -if (err) { -dev_err (pdsc->dev,"Cannot identify device: %pe\n" , -ERR_PTR (err)); +if (err)return err; - }if (isprint (pdsc->dev_info.fw_version[0 ]) &&isascii (pdsc->dev_info.fw_version[0 ]))
@@ -334,6 +340,26 @@ static int pdsc_identify(struct pdsc *pdsc)return 0 ; } +static int pdsc_identify (struct pdsc *pdsc) +{ +int err; + +/* Older firmware rejects anything but PDS_CORE_IDENTITY_VERSION_1 +* with PDS_RC_EVERSION (-EINVAL), so retry with V1 on version +* rejection. Don't retry on other errors like -ENXIO/-ETIMEDOUT +* which indicate firmware is not running or hung. +*/ + err =pdsc_identify_ver (pdsc,PDS_CORE_IDENTITY_VERSION_2 ); +if (err == -EINVAL ) + err =pdsc_identify_ver (pdsc,PDS_CORE_IDENTITY_VERSION_1 ); + +if (err) +dev_err (pdsc->dev,"Cannot identify device: %pe\n" , +ERR_PTR (err)); + +return err; +} +void pdsc_dev_uninit (struct pdsc *pdsc) {if (pdsc->intr_info) {
include/linux/pds/pds_core_if.h +4 -0
@@ -119,6 +119,8 @@ struct pds_core_drv_identity {* value in usecs to device units using: * device units = usecs * mult / div * @vif_types: How many of each VIF device type is supported +* @capabilities: Device capabilities +* only supported on version >= PDS_CORE_IDENTITY_VERSION_2 */ struct pds_core_dev_identity {u8 version;
@@ -131,9 +133,11 @@ struct pds_core_dev_identity {__le32 intr_coal_mult;__le32 intr_coal_div;__le16 vif_types[PDS_DEV_TYPE_MAX ]; +__le64 capabilities; };#define PDS_CORE_IDENTITY_VERSION_1 1 +#define PDS_CORE_IDENTITY_VERSION_2 2/** * struct pds_core_dev_identify_cmd - Driver/device identify command
Signature · 1 line
2.43.0
PATCH v12 3/6 pds_core: add PLDM firmware update support via devlink flash
In reply to Nikhil P. RaoFrom: Brett Creeley <[email protected]>
Implement PLDM FW Update in the pds_core driver using the upstream pldmfw API. This allows updating an entire PLDM FW package at once or updating specific firmware components by name.
Flash the entire image:
devlink dev flash pci/0000:b5:00.0 file firmware.pldmfw
Flash a specific component from the PLDM FW package:
devlink dev flash pci/0000:b5:00.0 \
file firmware.pldmfw component fw.cpld
Per-component update uses driver-defined component names (fw, fw.cpld, etc.). Not all components support per-component update - devlink will reject the request if the specified component cannot be updated.
--- .../device_drivers/ethernet/amd/pds_core.rst | 89 +++ drivers/net/ethernet/amd/Kconfig | 1 + drivers/net/ethernet/amd/pds_core/core.c | 9 + drivers/net/ethernet/amd/pds_core/core.h | 31 +- drivers/net/ethernet/amd/pds_core/dev.c | 82 +++ drivers/net/ethernet/amd/pds_core/devlink.c | 8 +- drivers/net/ethernet/amd/pds_core/fw.c | 796 ++++++++++++++++++++- drivers/net/ethernet/amd/pds_core/main.c | 5 + include/linux/pds/pds_core_if.h | 401 +++++++++++ 9 files changed, 1411 insertions(+), 11 deletions(-)
Documentation/networking/device_drivers/ethernet/amd/pds_core.rst +89 -0
@@ -102,6 +102,95 @@ currently in use, and that bank will used for the next boot:: # devlink dev flash pci/0000:b5:00.0 \ file pensando/dsc_fw_1.63.0-22.tar +Firmware Management (PLDM) +========================== + +Firmware that supports PLDM can be updated using the devlink flash command +with a PLDM firmware package. The entire package can be updated at once:: + + # devlink dev flash pci/0000:b5:00.0 file firmware.pldmfw + +Individual components can also be updated by specifying the component name:: + + # devlink dev flash pci/0000:b5:00.0 \ + file firmware.pldmfw component fw.cpld + +Per-component update uses driver-defined component names (fw, fw.cpld, +etc.). Not all components support per-component update - +devlink will reject the request if the specified component cannot +be updated. + +Gold (recovery) components can be updated by specifying the base component +name (e.g., ``fw`` for ``fw.gold``) with a goldfw package file when the +device supports per-component update. The ``.gold`` suffix in devlink info +output indicates the gold slot version, not a flash target. + +Info versions (PLDM) +==================== + +Firmware that supports PLDM reports component versions using driver-defined +names. The driver reports the following component versions: + +.. list-table:: devlink info versions for PLDM-capable firmware + :widths: 5 5 90 + + * - Name + - Type + - Description + * - ``fw`` + - running, stored + - Main firmware + * - ``fw.gold`` + - stored + - Gold (recovery) firmware + * - ``fw.bootloader`` + - running, stored + - Boot loader + * - ``fw.cpld`` + - running, stored + - CPLD + * - ``fw.secure`` + - running, stored + - Secure boot firmware + * - ``fw.fpga`` + - running, stored + - FPGA configuration + * - ``fw.suc`` + - running, stored + - System Unit Controller firmware + * - ``fw.suc.bootloader`` + - running, stored + - System Unit Controller bootloader + * - ``fw.uboot`` + - running, stored + - U-Boot bootloader + * - ``asic.id`` + - fixed + - The ASIC type for this device + * - ``asic.rev`` + - fixed + - The revision of the ASIC for this device + +Example output:: + + $ devlink dev info pci/0000:00:05.0 + pci/0000:00:05.0: + driver pds_core + serial_number FLM18420073 + versions: + fixed: + asic.id 0x0 + asic.rev 0x0 + running: + fw.bootloader 1.2.3 + fw 1.3.0 + fw.cpld 3.18 + stored: + fw.bootloader 1.2.3 + fw.gold 1.2.0 + fw 1.3.0 + fw.cpld 3.18 + Health Reporters ================
drivers/net/ethernet/amd/Kconfig +1 -0
@@ -171,6 +171,7 @@ config PDS_CORE depends on 64BIT && PCI select AUXILIARY_BUS select NET_DEVLINK + select PLDMFW help This enables the support for the AMD/Pensando Core device family of adapters. More specific information on this driver can be
drivers/net/ethernet/amd/pds_core/core.c +9 -0
@@ -489,6 +489,15 @@ void pdsc_teardown(struct pdsc *pdsc, bool removing)pdsc_devcmd_reset (pdsc);pci_clear_master (pdsc->pdev); +if (!pdsc->pdev->is_virtfn) { +u16 val; + +/* Flush any in-flight DMA before freeing buffers. +* A config read completion cannot return until all prior +* device-initiated memory writes have completed. +*/ +pci_read_config_word (pdsc->pdev,PCI_VENDOR_ID , &val); + }pdsc_core_uninit (pdsc);
drivers/net/ethernet/amd/pds_core/core.h +30 -1
@@ -23,6 +23,14 @@#define PDSC_SETUP_RECOVERY false#define PDSC_SETUP_INIT true +struct pdsc_deferred_dma { +struct list_head list; +dma_addr_t dma_addr; +void *va; +size_t size; +enum dma_data_direction dir; +}; +struct pdsc_dev_bar {void __iomem *vaddr;phys_addr_t bus_addr;
@@ -185,6 +193,8 @@ struct pdsc {struct mutex devcmd_lock;/* lock for dev_cmd operations */ struct mutex config_lock;/* lock for configuration operations */ spinlock_t adminq_lock;/* lock for adminq operations */ +struct list_head deferred_dma_list; +spinlock_t deferred_dma_lock;/* lock for deferred DMA list */ refcount_t adminq_refcnt;struct pds_core_dev_info_regs __iomem *info_regs;struct pds_core_dev_cmd_regs __iomem *cmd_regs;
@@ -199,6 +209,8 @@ struct pdsc {u64 last_eid;struct pdsc_viftype *viftype_status;struct work_struct pci_reset_work; + +struct pds_core_component_list_info fw_components; };/** enum pds_core_dbell_bits - bitwise composition of dbell values.
@@ -281,8 +293,16 @@ bool pdsc_is_fw_running(struct pdsc *pdsc);bool pdsc_is_fw_good (struct pdsc *pdsc);int pdsc_devcmd (struct pdsc *pdsc,union pds_core_dev_cmd *cmd,union pds_core_dev_comp *comp,int max_seconds); +int pdsc_devcmd_with_data (struct pdsc *pdsc,union pds_core_dev_cmd *cmd, +const void *data,size_t data_len, +union pds_core_dev_comp *comp,int max_seconds); +int pdsc_devcmd_with_data_nomsg (struct pdsc *pdsc,union pds_core_dev_cmd *cmd, +const void *data,size_t data_len, +union pds_core_dev_comp *comp,int max_seconds);int pdsc_devcmd_locked (struct pdsc *pdsc,union pds_core_dev_cmd *cmd,union pds_core_dev_comp *comp,int max_seconds); +int pdsc_devcmd_locked_nomsg (struct pdsc *pdsc,union pds_core_dev_cmd *cmd, +union pds_core_dev_comp *comp,int max_seconds);int pdsc_devcmd_init (struct pdsc *pdsc);int pdsc_devcmd_reset (struct pdsc *pdsc);int pdsc_dev_init (struct pdsc *pdsc);
@@ -315,11 +335,20 @@ void pdsc_process_adminq(struct pdsc_qcq *qcq);void pdsc_work_thread (struct work_struct *work);irqreturn_t pdsc_adminq_isr (int irq,void *data); -int pdsc_firmware_update (struct pdsc *pdsc,const struct firmware *fw, +int pdsc_firmware_update (struct pdsc *pdsc, +struct devlink_flash_update_params *params,struct netlink_ext_ack *extack); +int pdsc_get_component_info (struct pdsc *pdsc); +const char *pdsc_fw_type_to_name (u8 type); +void pdsc_fw_components_invalidate (struct pdsc *pdsc);void pdsc_fw_down (struct pdsc *pdsc);void pdsc_fw_up (struct pdsc *pdsc);void pdsc_pci_reset_thread (struct work_struct *work); +void pdsc_deferred_dma_add (struct pdsc *pdsc,struct pdsc_deferred_dma *entry, +dma_addr_t dma_addr,void *va,size_t size, +enum dma_data_direction dir); +void pdsc_deferred_dma_free (struct pdsc *pdsc); +#endif /* _PDSC_H_ */
drivers/net/ethernet/amd/pds_core/dev.c +82 -0
103 lines not on this page · raw message
drivers/net/ethernet/amd/pds_core/devlink.c +1 -7
@@ -90,13 +90,7 @@ int pdsc_dl_flash_update(struct devlink *dl, {struct pdsc *pdsc =devlink_priv (dl); -if (params->component) { -NL_SET_ERR_MSG_MOD (extack, -"Component update not supported by this device" ); -return -EOPNOTSUPP ; - } - -return pdsc_firmware_update (pdsc, params->fw, extack); +return pdsc_firmware_update (pdsc, params, extack); }static char *fw_slotnames[] = {
drivers/net/ethernet/amd/pds_core/fw.c +793 -3
830 lines not on this page · raw message
drivers/net/ethernet/amd/pds_core/main.c +5 -0
@@ -315,6 +315,7 @@ static int pdsc_init_pf(struct pdsc *pdsc)destroy_workqueue (pdsc->wq);mutex_destroy (&pdsc->config_lock);mutex_destroy (&pdsc->devcmd_lock); +pdsc_deferred_dma_free (pdsc);pci_free_irq_vectors (pdsc->pdev); err_out_unmap_bars:pdsc_unmap_bars (pdsc);
@@ -353,6 +354,8 @@ static int pdsc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) pdsc->pdev = pdev; pdsc->dev = &pdev->dev;set_bit (PDSC_S_INITING_DRIVER , &pdsc->state); +INIT_LIST_HEAD (&pdsc->deferred_dma_list); +spin_lock_init (&pdsc->deferred_dma_lock);pci_set_drvdata (pdev, pdsc);pdsc_debugfs_add_dev (pdsc);
@@ -458,6 +461,7 @@ static void pdsc_remove(struct pci_dev *pdev) }pci_disable_device (pdev); +pdsc_deferred_dma_free (pdsc);ida_free (&pdsc_ida, pdsc->uid);pdsc_debugfs_del_dev (pdsc);
@@ -505,6 +509,7 @@ static void pdsc_reset_prepare(struct pci_dev *pdev)pci_release_regions (pdev);if (pci_is_enabled (pdev))pci_disable_device (pdev); +pdsc_deferred_dma_free (pdsc); }static void pdsc_reset_done (struct pci_dev *pdev)
include/linux/pds/pds_core_if.h +401 -0
454 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v12 4/6 pds_core: add PLDM component info display
In reply to Nikhil P. RaoFrom: Brett Creeley <[email protected]>
Add detailed component information display via devlink info. This allows users to see individual firmware components and their versions. Components are reported as fixed, running, or stored based on their firmware-provided flags.
Example output:
$ devlink dev info pci/0000:00:05.0
versions:
fixed:
asic.id 0x0
asic.rev 0x0
running:
fw.bootloader 1.2.3
fw.uboot 1.60.0-73
fw 1.60.0-73
fw.cpld 3.18
stored:
fw.bootloader 1.2.3
fw.uboot 1.60.0-73
fw.uboot.gold 1.50.0-22
fw.gold 1.50.0-22
fw 1.60.0-73
fw.cpld 3.18--- drivers/net/ethernet/amd/pds_core/core.c | 2 + drivers/net/ethernet/amd/pds_core/devlink.c | 145 +++++++++++++++++++++++++++- 2 files changed, 142 insertions(+), 5 deletions(-)
drivers/net/ethernet/amd/pds_core/core.c +2 -0
@@ -596,6 +596,8 @@ void pdsc_fw_up(struct pdsc *pdsc)return ; } +pdsc_fw_components_invalidate (pdsc); + err =pdsc_setup (pdsc,PDSC_SETUP_RECOVERY );if (err) goto err_out;
drivers/net/ethernet/amd/pds_core/devlink.c +140 -5
166 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v12 5/6 pds_core: add host backed memory support for firmware
In reply to Nikhil P. RaoSome newer AMD/Pensando cards have minimal memory and there are cases where components, specifically in the control plane, need more memory. This series adds support for host backed DMA memory that can be used by the firmware for the previously mentioned cases.
Host memory allocation is best-effort: if some allocations fail, the driver continues with whatever succeeded. Firmware gracefully degrades when less memory is available than requested.
--- drivers/net/ethernet/amd/pds_core/core.c | 160 +++++++++++++++++++++++++++++++ drivers/net/ethernet/amd/pds_core/core.h | 22 +++++ drivers/net/ethernet/amd/pds_core/main.c | 2 + include/linux/pds/pds_core_if.h | 64 +++++++++++++ 4 files changed, 248 insertions(+)
drivers/net/ethernet/amd/pds_core/core.c +160 -0
@@ -506,6 +506,7 @@ void pdsc_teardown(struct pdsc *pdsc, bool removing) pdsc->viftype_status =NULL ; } +pdsc_host_mem_free (pdsc);pdsc_dev_uninit (pdsc);set_bit (PDSC_S_FW_DEAD , &pdsc->state);
@@ -515,6 +516,7 @@ int pdsc_start(struct pdsc *pdsc) {pds_core_intr_mask (&pdsc->intr_ctrl[pdsc->adminqcq.intx],PDS_CORE_INTR_MASK_CLEAR ); +pdsc_host_mem_add (pdsc);return 0 ; }
@@ -681,3 +683,161 @@ void pdsc_health_thread(struct work_struct *work) out_unlock:mutex_unlock (&pdsc->config_lock); } + +static void pdsc_host_mem_del_one (struct pdsc *pdsc,u16 tag,u8 reason) +{ +union pds_core_dev_comp comp = {}; +union pds_core_dev_cmd cmd = { + .host_mem.opcode =PDS_CORE_CMD_HOST_MEM , + .host_mem.oper =PDS_CORE_HOST_MEM_DEL , + .host_mem.tag =cpu_to_le16 (tag), + .host_mem.reason = reason, + }; + +dev_dbg (pdsc->dev,"Sending devcmd for mem del tag %d\n" , tag); +pdsc_devcmd (pdsc, &cmd, &comp, pdsc->devcmd_timeout); +} + +static int pdsc_host_mem_add_one (struct pdsc *pdsc,int index) +{ +struct pdsc_host_mem *hm = &pdsc->host_mem_reqs[index]; +union pds_core_dev_comp comp = {}; +union pds_core_dev_cmd cmd = {}; +int err; + + cmd.host_mem.opcode =PDS_CORE_CMD_HOST_MEM ; + cmd.host_mem.oper =PDS_CORE_HOST_MEM_QUERY ; + cmd.host_mem.index =cpu_to_le16 (index); +dev_dbg (pdsc->dev,"Sending devcmd for mem query index %d\n" , index); + err =pdsc_devcmd (pdsc, &cmd, &comp, pdsc->devcmd_timeout); +if (err || comp.status !=PDS_RC_SUCCESS ) { +dev_err (pdsc->dev,"mem query failed err %d status %d\n" , + err, comp.status); +return err ? err : -EIO ; + } + hm->size =le32_to_cpu (comp.host_mem.size); + hm->tag =le16_to_cpu (comp.host_mem.tag); +dev_dbg (pdsc->dev,"mem query returned size %d tag %d\n" , + hm->size, hm->tag); + +if (!hm->size || hm->size >PDSC_HOST_MEM_MAX_CONTIG ) { +dev_err (pdsc->dev,"invalid size %d for tag %d\n" , + hm->size, hm->tag); + err = -EINVAL ; + goto err_del; + } + + hm->order =get_order (hm->size); + hm->pg =alloc_pages (GFP_KERNEL | __GFP_ZERO | __GFP_NOWARN, hm->order); +if (!hm->pg) { +dev_warn (pdsc->dev,"alloc order %d failed for tag %d\n" , + hm->order, hm->tag); + err = -ENOMEM ; + goto err_del; + } + + hm->pa =dma_map_page (pdsc->dev, hm->pg,0 , hm->size, +DMA_BIDIRECTIONAL ); +if (dma_mapping_error (pdsc->dev, hm->pa)) { +dev_err (pdsc->dev,"dma map failed for tag %d size %d\n" , + hm->tag, hm->size); +__free_pages (hm->pg, hm->order); + hm->pg =NULL ; + err = -EIO ; + goto err_del; + } + +/* Track this allocation so pdsc_host_mem_free() can clean it up */ + pdsc->num_host_mem_reqs++; + +memset (&cmd,0 ,sizeof (cmd)); +memset (&comp,0 ,sizeof (comp)); + cmd.host_mem.opcode =PDS_CORE_CMD_HOST_MEM ; + cmd.host_mem.oper =PDS_CORE_HOST_MEM_ADD ; + cmd.host_mem.tag =cpu_to_le16 (hm->tag); + cmd.host_mem.size =cpu_to_le32 (hm->size); + cmd.host_mem.buf_pa =cpu_to_le64 (hm->pa); + +dev_dbg (pdsc->dev,"Sending devcmd for mem add tag %d size %d pa %pad\n" , + hm->tag, hm->size, &hm->pa); + err =pdsc_devcmd (pdsc, &cmd, &comp, pdsc->devcmd_timeout); +if (err || comp.status !=PDS_RC_SUCCESS ) { +dev_err (pdsc->dev,"mem add failed err %d status %d for tag %d\n" , + err, comp.status, hm->tag); + err = err ? err : -EIO ; + goto err_del; + } +dev_dbg (pdsc->dev,"mem add completed for tag %d\n" , hm->tag); + +return 0 ; + +err_del: +/* After MEM_QUERY succeeds, firmware expects MEM_ADD or MEM_DEL */ +pdsc_host_mem_del_one (pdsc, hm->tag,PDS_RC_ENOMEM ); +return err; +} + +void pdsc_host_mem_add (struct pdsc *pdsc) +{ +union pds_core_dev_comp comp = {}; +union pds_core_dev_cmd cmd = {}; +u16 count; +int err; +int i; + +if (!(pdsc->dev_ident.capabilities & +cpu_to_le64 (PDS_CORE_DEV_CAP_HOST_MEM ))) +return ; + + cmd.host_mem.opcode =PDS_CORE_CMD_HOST_MEM ; + cmd.host_mem.oper =PDS_CORE_HOST_MEM_GET_COUNT ; + cmd.host_mem.index =cpu_to_le16 (PDSC_HOST_MEM_MAX_COUNT ); + cmd.host_mem.max_contig =cpu_to_le32 (PDSC_HOST_MEM_MAX_CONTIG ); +dev_dbg (pdsc->dev,"Sending devcmd for mem get count max_contig %u\n" , +PDSC_HOST_MEM_MAX_CONTIG ); + err =pdsc_devcmd (pdsc, &cmd, &comp, pdsc->devcmd_timeout); +if (err || comp.status !=PDS_RC_SUCCESS ) { +dev_err (pdsc->dev,"mem get count failed err %d status %d\n" , + err, comp.status); +return ; + } + + count =min (le16_to_cpu (comp.host_mem.count), +PDSC_HOST_MEM_MAX_COUNT ); +dev_dbg (pdsc->dev,"mem get count returned count %d\n" , count); +if (count ==0 ) +return ; + + pdsc->host_mem_reqs =kzalloc_objs (*pdsc->host_mem_reqs, count, +GFP_KERNEL ); +if (!pdsc->host_mem_reqs) { +dev_err (pdsc->dev,"failed to alloc host_mem_reqs array\n" ); +return ; + } + +for (i =0 ; i < count; i++) { + err =pdsc_host_mem_add_one (pdsc, i); +if (err) +break ; + } +} + +void pdsc_host_mem_free (struct pdsc *pdsc) +{ +int i; + +if (!pdsc->host_mem_reqs) +return ; + +for (i =0 ; i < pdsc->num_host_mem_reqs; i++) { +dma_unmap_page (pdsc->dev, pdsc->host_mem_reqs[i].pa, + pdsc->host_mem_reqs[i].size, +DMA_BIDIRECTIONAL ); +__free_pages (pdsc->host_mem_reqs[i].pg, + pdsc->host_mem_reqs[i].order); + } + +kfree (pdsc->host_mem_reqs); + pdsc->host_mem_reqs =NULL ; + pdsc->num_host_mem_reqs =0 ; +}
drivers/net/ethernet/amd/pds_core/core.h +22 -0
@@ -5,6 +5,7 @@#define _PDSC_H_#include <linux/debugfs.h> +#include <linux/mmzone.h> #include <net/devlink.h> #include <linux/pds/pds_common.h>
@@ -23,6 +24,12 @@#define PDSC_SETUP_RECOVERY false#define PDSC_SETUP_INIT true +/* Use fixed 4MB instead of PAGE_SIZE << MAX_PAGE_ORDER to avoid +* cpu_to_le32() truncation on large-page configs +*/ +#define PDSC_HOST_MEM_MAX_CONTIG (4 * 1024 * 1024) +#define PDSC_HOST_MEM_MAX_COUNT 256 +struct pdsc_deferred_dma {struct list_head list;dma_addr_t dma_addr;
@@ -149,6 +156,14 @@ struct pdsc_viftype {struct pds_auxiliary_dev *padev; }; +struct pdsc_host_mem { +u32 size; +u16 tag; +u8 order; +struct page *pg; +dma_addr_t pa; +}; +/* No state flags set means we are in a steady running state */ enum pdsc_state_flags {PDSC_S_FW_DEAD ,/* stopped, wait on startup or recovery */
@@ -210,6 +225,9 @@ struct pdsc {struct pdsc_viftype *viftype_status;struct work_struct pci_reset_work; +struct pdsc_host_mem *host_mem_reqs; +u16 num_host_mem_reqs; +struct pds_core_component_list_info fw_components; };
@@ -287,6 +305,7 @@ void pdsc_debugfs_add_viftype(struct pdsc *pdsc);void pdsc_debugfs_add_irqs (struct pdsc *pdsc);void pdsc_debugfs_add_qcq (struct pdsc *pdsc,struct pdsc_qcq *qcq);void pdsc_debugfs_del_qcq (struct pdsc_qcq *qcq); +void pdsc_debugfs_add_host_mem (struct pdsc *pdsc);int pdsc_err_to_errno (enum pds_core_status_code code);bool pdsc_is_fw_running (struct pdsc *pdsc);
@@ -346,6 +365,9 @@ void pdsc_fw_down(struct pdsc *pdsc);void pdsc_fw_up (struct pdsc *pdsc);void pdsc_pci_reset_thread (struct work_struct *work); +void pdsc_host_mem_add (struct pdsc *pdsc); +void pdsc_host_mem_free (struct pdsc *pdsc); +void pdsc_deferred_dma_add (struct pdsc *pdsc,struct pdsc_deferred_dma *entry,dma_addr_t dma_addr,void *va,size_t size,enum dma_data_direction dir);
drivers/net/ethernet/amd/pds_core/main.c +2 -0
@@ -21,6 +21,8 @@ static const struct pci_device_id pdsc_id_table[] = { };MODULE_DEVICE_TABLE (pci, pdsc_id_table); +static void pdsc_stop_health_thread (struct pdsc *pdsc); +static void pdsc_wdtimer_cb (struct timer_list *t) {struct pdsc *pdsc =timer_container_of (pdsc, t, wdtimer);
include/linux/pds/pds_core_if.h +64 -0
97 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v12 6/6 pds_core: add debugfs support for host backed memory
In reply to Nikhil P. RaoAdd debugfs entry to dump host backed memory allocations for debug purposes.
--- drivers/net/ethernet/amd/pds_core/core.c | 2 ++ drivers/net/ethernet/amd/pds_core/core.h | 1 + drivers/net/ethernet/amd/pds_core/debugfs.c | 45 +++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+)
drivers/net/ethernet/amd/pds_core/core.c +2 -0
@@ -506,6 +506,7 @@ void pdsc_teardown(struct pdsc *pdsc, bool removing) pdsc->viftype_status =NULL ; } +pdsc_debugfs_del_host_mem (pdsc);pdsc_host_mem_free (pdsc);pdsc_dev_uninit (pdsc);
@@ -517,6 +518,7 @@ int pdsc_start(struct pdsc *pdsc)pds_core_intr_mask (&pdsc->intr_ctrl[pdsc->adminqcq.intx],PDS_CORE_INTR_MASK_CLEAR );pdsc_host_mem_add (pdsc); +pdsc_debugfs_add_host_mem (pdsc);return 0 ; }
drivers/net/ethernet/amd/pds_core/core.h +1 -0
@@ -306,6 +306,7 @@ void pdsc_debugfs_add_irqs(struct pdsc *pdsc);void pdsc_debugfs_add_qcq (struct pdsc *pdsc,struct pdsc_qcq *qcq);void pdsc_debugfs_del_qcq (struct pdsc_qcq *qcq);void pdsc_debugfs_add_host_mem (struct pdsc *pdsc); +void pdsc_debugfs_del_host_mem (struct pdsc *pdsc);int pdsc_err_to_errno (enum pds_core_status_code code);bool pdsc_is_fw_running (struct pdsc *pdsc);
drivers/net/ethernet/amd/pds_core/debugfs.c +45 -0
48 lines not on this page · raw message
Signature · 1 line
2.43.0
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 11 lines · On Thu, 30 Jul 2026 04:25:17 +0000 you wrote:
This series adds PLDM-based firmware update support to the
pds_coredriver. PLDM (Platform Level Data Model) is a DMTF standard for firmware management that provides a vendor-neutral interface for firmware updates.The implementation uses the kernel's pldmfw library for package parsing and component matching. Users can update entire firmware packages or individual components via devlink flash. Component information is displayed via devlink info, showing firmware versions and update status for each component.
[...]
Here is the summary with links:
- [net-next,v12,1/6] pds_core: add support for quiet devcmd failures
https://git.kernel.org/netdev/net-next/c/4b5137bfc07b - [net-next,v12,2/6] pds_core: add support for identity version 2 https://git.kernel.org/netdev/net-next/c/e7960459d977 - [net-next,v12,3/6] pds_core: add PLDM firmware update support via devlink flash https://git.kernel.org/netdev/net-next/c/fb918581d433 - [net-next,v12,4/6] pds_core: add PLDM component info display https://git.kernel.org/netdev/net-next/c/5df545b3a5ee - [net-next,v12,5/6] pds_core: add host backed memory support for firmware https://git.kernel.org/netdev/net-next/c/b311af86b58f - [net-next,v12,6/6] pds_core: add debugfs support for host backed memory https://git.kernel.org/netdev/net-next/c/0b5091b64ad6
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html