Skip to content

Commit

Permalink
pldmfw: enable selected component update
Browse files Browse the repository at this point in the history
This patch enables to update a selected component from PLDM image
containing multiple components.

Example usage:

struct pldmfw;
data.mode = PLDMFW_UPDATE_MODE_SINGLE_COMPONENT;
data.compontent_identifier = DRIVER_FW_MGMT_COMPONENT_ID;

Reviewed-by: Jacob Keller <[email protected]>
Reviewed-by: Marcin Szycik <[email protected]>
Reviewed-by: Przemek Kitszel <[email protected]>
Signed-off-by: Konrad Knitter <[email protected]>
Tested-by: Pucha Himasekhar Reddy <[email protected]> (A Contingent worker at Intel)
Signed-off-by: Tony Nguyen <[email protected]>
  • Loading branch information
konradknitter authored and anguy11 committed Jan 16, 2025
1 parent b44e27b commit d4679b7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions include/linux/pldmfw.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,17 @@ struct pldmfw_ops;
* a pointer to their own data, used to implement the device specific
* operations.
*/

enum pldmfw_update_mode {
PLDMFW_UPDATE_MODE_FULL,
PLDMFW_UPDATE_MODE_SINGLE_COMPONENT,
};

struct pldmfw {
const struct pldmfw_ops *ops;
struct device *dev;
u16 component_identifier;
enum pldmfw_update_mode mode;
};

bool pldmfw_op_pci_match_record(struct pldmfw *context, struct pldmfw_record *record);
Expand Down
8 changes: 8 additions & 0 deletions lib/pldmfw/pldmfw.c
Original file line number Diff line number Diff line change
Expand Up @@ -481,9 +481,17 @@ static int pldm_parse_components(struct pldmfw_priv *data)
component->component_data = data->fw->data + offset;
component->component_size = size;

if (data->context->mode == PLDMFW_UPDATE_MODE_SINGLE_COMPONENT &&
data->context->component_identifier != component->identifier)
continue;

list_add_tail(&component->entry, &data->components);
}

if (data->context->mode == PLDMFW_UPDATE_MODE_SINGLE_COMPONENT &&
list_empty(&data->components))
return -ENOENT;

header_crc_ptr = data->fw->data + data->offset;

err = pldm_move_fw_offset(data, sizeof(data->header_crc));
Expand Down

0 comments on commit d4679b7

Please sign in to comment.