From: Srinivasulu Thanneeru <sthanneeru.opensrc@xxxxxxxxxx> The CXL 3.0 specification outlines background operations, and support for handling these operations was added in following patch. Link: https://lore.kernel.org/all/20230523170927.20685-5-dave@xxxxxxxxxxxx/ Mailbox commands like ‘Log Populate’ use background operations to complete the execution of the command. This can lead to a timeout, since there is currently no option in the ioctl cxl_send_command structure to specify a timeout value. The default values being zero can lead to the driver reporting false negatives to the application. This patch aims to establish default values, enabling mailbox commands that operate in the background to continue functioning even if a timeout is not set in the userspace application. Signed-off-by: Srinivasulu Thanneeru <sthanneeru.opensrc@xxxxxxxxxx> --- drivers/cxl/pci.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/cxl/pci.c b/drivers/cxl/pci.c index 4fd1f207c84e..82bdff55bb8d 100644 --- a/drivers/cxl/pci.c +++ b/drivers/cxl/pci.c @@ -40,6 +40,10 @@ /* CXL 2.0 - 8.2.8.4 */ #define CXL_MAILBOX_TIMEOUT_MS (2 * HZ) +/* Default timeout for background operations */ +#define CXL_RC_BG_POLL_CNT 40 +#define CXL_RC_BG_POLL_INTERVAL_MS 1000 + /* * CXL 2.0 ECN "Add Mailbox Ready Time" defines a capability field to * dictate how long to wait for the mailbox to become ready. The new @@ -312,6 +316,13 @@ static int __cxl_pci_mbox_send_cmd(struct cxl_memdev_state *mds, dev_dbg(dev, "Mailbox background operation (0x%04x) started\n", mbox_cmd->opcode); + /* + * Set default background operation timeout, if not set already. + */ + if (!mbox_cmd->poll_count) + mbox_cmd->poll_count = CXL_RC_BG_POLL_CNT; + if (!mbox_cmd->poll_interval_ms) + mbox_cmd->poll_interval_ms = CXL_RC_BG_POLL_INTERVAL_MS; timeout = mbox_cmd->poll_interval_ms; for (i = 0; i < mbox_cmd->poll_count; i++) { -- 2.43.0