[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PULL 55/63] hw/cxl/mbox: Add support for background operations
|
From: |
Peter Maydell |
|
Subject: |
Re: [PULL 55/63] hw/cxl/mbox: Add support for background operations |
|
Date: |
Thu, 9 Nov 2023 14:44:17 +0000 |
On Tue, 7 Nov 2023 at 10:13, Michael S. Tsirkin <mst@redhat.com> wrote:
>
> From: Davidlohr Bueso <dave@stgolabs.net>
>
> Support background commands in the mailbox, and update
> cmd_infostat_bg_op_sts() accordingly. This patch does not implement mbox
> interrupts upon completion, so the kernel driver must rely on polling to
> know when the operation is done.
>
> Signed-off-by: Davidlohr Bueso <dave@stgolabs.net>
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>
> Message-Id: <20231023160806.13206-12-Jonathan.Cameron@huawei.com>
> Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Hi; Coverity points out dead code in this function (CID 1523907):
> +static void bg_timercb(void *opaque)
> +{
> + CXLCCI *cci = opaque;
> + CXLDeviceState *cxl_dstate = &CXL_TYPE3(cci->d)->cxl_dstate;
> + uint64_t bg_status_reg = 0;
> + uint64_t now = qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL);
> + uint64_t total_time = cci->bg.starttime + cci->bg.runtime;
> +
> + assert(cci->bg.runtime > 0);
> + bg_status_reg = FIELD_DP64(bg_status_reg, CXL_DEV_BG_CMD_STS,
> + OP, cci->bg.opcode);
> +
> + if (now >= total_time) { /* we are done */
> + uint64_t status_reg;
> + uint16_t ret = CXL_MBOX_SUCCESS;
Here we set 'ret' to CXL_MBOX_SUCCESS...
> +
> + cci->bg.complete_pct = 100;
> + /* Clear bg */
> + status_reg = FIELD_DP64(0, CXL_DEV_MAILBOX_STS, BG_OP, 0);
> + cxl_dstate->mbox_reg_state64[R_CXL_DEV_MAILBOX_STS] = status_reg;
> +
> + bg_status_reg = FIELD_DP64(bg_status_reg, CXL_DEV_BG_CMD_STS,
> + RET_CODE, ret);
...and nothing here changes 'ret'...
> +
> + /* TODO add ad-hoc cmd succesful completion handling */
> +
> + qemu_log("Background command %04xh finished: %s\n",
> + cci->bg.opcode,
> + ret == CXL_MBOX_SUCCESS ? "success" : "aborted");
...but here we check whether ret is CXL_MBOX_SUCCESS or not:
the "aborted" half of this condition is dead code.
A later commit adds an "if (ret == CXL_MBOX_SUCCESS) {" block
where the TODO currently is, and that is an unnecessary check,
because ret cannot be anything else at that point.
> + } else {
> + /* estimate only */
> + cci->bg.complete_pct = 100 * now / total_time;
> + timer_mod(cci->bg.timer, now + CXL_MBOX_BG_UPDATE_FREQ);
> + }
What was the intention here ?
thanks
-- PMM
- [PULL 47/63] hw/cxl/mbox: Pull the CCI definition out of the CXLDeviceState, (continued)
- [PULL 47/63] hw/cxl/mbox: Pull the CCI definition out of the CXLDeviceState, Michael S. Tsirkin, 2023/11/07
- [PULL 46/63] hw/cxl/mbox: Split mailbox command payload into separate input and output, Michael S. Tsirkin, 2023/11/07
- [PULL 49/63] hw/pci-bridge/cxl_upstream: Move defintion of device to header., Michael S. Tsirkin, 2023/11/07
- [PULL 50/63] hw/cxl: Add a switch mailbox CCI function, Michael S. Tsirkin, 2023/11/07
- [PULL 48/63] hw/cxl/mbox: Generalize the CCI command processing, Michael S. Tsirkin, 2023/11/07
- [PULL 53/63] hw/pci-bridge/cxl_downstream: Set default link width and link speed, Michael S. Tsirkin, 2023/11/07
- [PULL 52/63] hw/cxl/mbox: Add Physical Switch Identify command., Michael S. Tsirkin, 2023/11/07
- [PULL 54/63] hw/cxl: Implement Physical Ports status retrieval, Michael S. Tsirkin, 2023/11/07
- [PULL 51/63] hw/cxl/mbox: Add Information and Status / Identify command, Michael S. Tsirkin, 2023/11/07
- [PULL 55/63] hw/cxl/mbox: Add support for background operations, Michael S. Tsirkin, 2023/11/07
- Re: [PULL 55/63] hw/cxl/mbox: Add support for background operations,
Peter Maydell <=
- [PULL 56/63] hw/cxl/mbox: Wire up interrupts for background completion, Michael S. Tsirkin, 2023/11/07
- [PULL 57/63] hw/cxl: Add support for device sanitation, Michael S. Tsirkin, 2023/11/07
- [PULL 59/63] hw/cxl/type3: Cleanup multiple CXL_TYPE3() calls in read/write functions, Michael S. Tsirkin, 2023/11/07
- [PULL 60/63] hw/cxl: Add dummy security state get, Michael S. Tsirkin, 2023/11/07
- [PULL 61/63] hw/cxl: Add tunneled command support to mailbox for switch cci., Michael S. Tsirkin, 2023/11/07
- [PULL 58/63] hw/cxl/mbox: Add Get Background Operation Status Command, Michael S. Tsirkin, 2023/11/07
- [PULL 63/63] acpi/tests/avocado/bits: enable console logging from bits VM, Michael S. Tsirkin, 2023/11/07