From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
To: Davidlohr Bueso <dave@stgolabs.net>
Cc: <dave.jiang@intel.com>, <dan.j.williams@intel.com>,
<alison.schofield@intel.com>, <vishal.l.verma@intel.com>,
<ira.weiny@intel.com>, <jgroves@micron.com>,
<ravis.opensrc@micron.com>, <fan.ni@samsung.com>,
<anisa.su@samsung.com>, <a.manzanares@samsung.com>,
<linux-cxl@vger.kernel.org>
Subject: Re: [PATCH 5/7] cxl/mbox: Allow userspace background commands
Date: Mon, 23 Jun 2025 15:49:59 +0100 [thread overview]
Message-ID: <20250623154959.00005d54@huawei.com> (raw)
In-Reply-To: <20250617193611.564668-6-dave@stgolabs.net>
On Tue, 17 Jun 2025 12:36:09 -0700
Davidlohr Bueso <dave@stgolabs.net> wrote:
> CXL 3.1 introduced the ability to request that the current on-going
> background command be aborted. As such userspace may be allowed to
> monopolize the background operation capability if there are no
> other bg commands that want to run.
>
> The policy here are as follows:
>
> 1. Give bg-capable commands from the kernel higher priority than those
> from userspace (albeit currently no command). Therefore a userspace
> on-going command can be canceled so a kernel one may run instead.
>
> 2. Userspace bg commands may cancel each other on demand. It is not
> up to the kernel to put any policies in place here.
>
> 3. Any previously synchronous polling timedout command that is still
> running may also be aborted by any command. This window is expected
> to be small.
>
> The context of doing the cancellation request is the same as the new
> incoming command, and will always hold the mbox_mutex, guaranteeing
> that any successful cancel does not race with a third thread coming
> in and stealing the effort.
>
> Signed-off-by: Davidlohr Bueso <dave@stgolabs.net>
> ---
> drivers/cxl/core/mbox.c | 9 ++++--
> drivers/cxl/cxlmem.h | 4 +++
> drivers/cxl/pci.c | 72 +++++++++++++++++++++++++++++++++++++----
> include/cxl/mailbox.h | 2 ++
> 4 files changed, 78 insertions(+), 9 deletions(-)
> diff --git a/drivers/cxl/pci.c b/drivers/cxl/pci.c
> index 3648efcc7c89..6ada0f502914 100644
> --- a/drivers/cxl/pci.c
> +++ b/drivers/cxl/pci.c
> @@ -263,6 +264,8 @@ static int __cxl_pci_mbox_send_cmd(struct cxl_mailbox *cxl_mbox,
> * commands during this window.
> */
> switch (mds->bg.opcode) {
> + case 0:
I assume this is the race? Add a comment so we can figure this out in future.
> + break;
> case CXL_MBOX_OP_SANITIZE:
> /*
> * Ensure no new command comes in until so. Keep the
> static int cxl_pci_mbox_send(struct cxl_mailbox *cxl_mbox,
> struct cxl_mbox_cmd *cmd)
> {
> @@ -381,9 +437,11 @@ static int cxl_pci_mbox_send(struct cxl_mailbox *cxl_mbox,
> /*
> * Ensure cxl_mbox_background_done() checks are safe amongst
> * each other: no new bg operation can occur in between while polling.
> + *
Stray change.
> */
next prev parent reply other threads:[~2025-06-23 14:50 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-17 19:36 [PATCH 0/7] cxl: Activate FW and userspace bgcmds Davidlohr Bueso
2025-06-17 19:36 ` [PATCH 1/7] cxl/mbox: Track background commands from CEL Davidlohr Bueso
2025-06-23 14:16 ` Jonathan Cameron
2025-06-23 16:19 ` Davidlohr Bueso
2025-06-17 19:36 ` [PATCH 2/7] cxl/mbox: Handle Activate FW as async bg Davidlohr Bueso
2025-06-23 14:22 ` Jonathan Cameron
2025-06-17 19:36 ` [PATCH 3/7] cxl/pci: Lockless background synchronous polling Davidlohr Bueso
2025-06-23 14:29 ` Jonathan Cameron
2025-06-23 16:23 ` Davidlohr Bueso
2025-06-17 19:36 ` [PATCH 4/7] cxl/mbox: Stronger cxl_mbox_background_complete() semantics Davidlohr Bueso
2025-06-23 14:31 ` Jonathan Cameron
2025-06-17 19:36 ` [PATCH 5/7] cxl/mbox: Allow userspace background commands Davidlohr Bueso
2025-06-23 14:49 ` Jonathan Cameron [this message]
2025-06-17 19:36 ` [PATCH 6/7] cxl/mbox: Shout upon async bgcmd race Davidlohr Bueso
2025-06-23 14:50 ` Jonathan Cameron
2025-06-23 16:14 ` Davidlohr Bueso
2025-06-17 21:52 ` [PATCH 0/7] cxl: Activate FW and userspace bgcmds Davidlohr Bueso
2025-06-17 22:15 ` [PATCH 7/7] cxl/mbox: Add Populate Log support Davidlohr Bueso
2025-06-23 14:51 ` 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=20250623154959.00005d54@huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=a.manzanares@samsung.com \
--cc=alison.schofield@intel.com \
--cc=anisa.su@samsung.com \
--cc=dan.j.williams@intel.com \
--cc=dave.jiang@intel.com \
--cc=dave@stgolabs.net \
--cc=fan.ni@samsung.com \
--cc=ira.weiny@intel.com \
--cc=jgroves@micron.com \
--cc=linux-cxl@vger.kernel.org \
--cc=ravis.opensrc@micron.com \
--cc=vishal.l.verma@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.