Re: [PATCH v2 4/4] tools/testing/cxl: add firmware update emulation to CXL memdevs

From: Jonathan Cameron
Date: Thu Jun 08 2023 - 10:54:44 EST


On Mon, 05 Jun 2023 14:20:25 -0600
Vishal Verma <vishal.l.verma@xxxxxxxxx> wrote:

> Add emulation for the 'Get FW Info', 'Transfer FW', and 'Activate FW'
> CXL mailbox commands to the cxl_test emulated memdevs to enable
> end-to-end unit testing of a firmware update flow. For now, only
> advertise an 'offline activation' capability as that is all the CXL
> memdev driver currently implements.
>
> Add some canned values for the serial number fields, and create a
> platform device sysfs knob to calculate the sha256sum of the firmware
> image that was received, so a unit test can compare it with the original
> file that was uploaded.
>
> Cc: Davidlohr Bueso <dave@xxxxxxxxxxxx>
> Cc: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx>
> Cc: Russ Weight <russell.h.weight@xxxxxxxxx>
> Cc: Alison Schofield <alison.schofield@xxxxxxxxx>
> Cc: Ira Weiny <ira.weiny@xxxxxxxxx>
> Cc: Dave Jiang <dave.jiang@xxxxxxxxx>
> Cc: Ben Widawsky <bwidawsk@xxxxxxxxxx>
> Cc: Dan Williams <dan.j.williams@xxxxxxxxx>
> Signed-off-by: Vishal Verma <vishal.l.verma@xxxxxxxxx>

One trivial comment inline.

I've somewhat lost track of the test utils, so less comfortable on reviewing
them than the kernel code. With that in mind this looks good to me.

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx>

> ---
> tools/testing/cxl/test/mem.c | 162 +++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 162 insertions(+)
>


> +static int mock_activate_fw(struct cxl_dev_state *cxlds,
> + struct cxl_mbox_cmd *cmd)
> +{
> + struct cxl_mbox_activate_fw *activate = cmd->payload_in;
> + struct cxl_mockmem_data *mdata = dev_get_drvdata(cxlds->dev);
> +
> + if (activate->slot == 0 || activate->slot > FW_SLOTS)
> + return -EINVAL;
> +
> + switch (activate->action) {
> + case CXL_FW_ACTIVATE_ONLINE:
> + mdata->fw_slot = activate->slot;
> + mdata->fw_staged = 0;
> + break;
> + case CXL_FW_ACTIVATE_OFFLINE:
> + mdata->fw_staged = activate->slot;
> + break;
> + default:
> + return -EINVAL;
> + }
> +
> + return 0;

Might as well push the return 0 up to the cases instead of breaking out.


>