linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: <sthanneeru.opensrc@micron.com>
To: <linux-cxl@vger.kernel.org>, <linux-mm@kvack.org>,
	<sthanneeru.opensrc@micron.com>
Cc: <Jonathan.Cameron@huawei.com>, <dan.j.williams@intel.com>,
	<john@jagalactic.com>, <emirakhur@micron.com>,
	<ajayjoshi@micron.com>, <Ravis.OpenSrc@micron.com>,
	<sthanneeru@micron.com>
Subject: [RFC PATCH] cxl/pci: Set default timeout for background operations
Date: Wed, 7 Feb 2024 16:23:49 +0530	[thread overview]
Message-ID: <20240207105349.301-1-sthanneeru.opensrc@micron.com> (raw)

From: Srinivasulu Thanneeru <sthanneeru.opensrc@micron.com>

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@stgolabs.net/

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@micron.com>
---
 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



             reply	other threads:[~2024-02-07 10:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-07 10:53 sthanneeru.opensrc [this message]
2024-02-15  3:31 ` Dan Williams
2024-02-15 12:34   ` Jonathan Cameron
2024-09-02  6:42 Shinas Rasheed
2024-09-13 11:52 ` Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240207105349.301-1-sthanneeru.opensrc@micron.com \
    --to=sthanneeru.opensrc@micron.com \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=Ravis.OpenSrc@micron.com \
    --cc=ajayjoshi@micron.com \
    --cc=dan.j.williams@intel.com \
    --cc=emirakhur@micron.com \
    --cc=john@jagalactic.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=sthanneeru@micron.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox