cxl/mbox: Add sanitization handling machinery
authorDavidlohr Bueso <dave@stgolabs.net>
Mon, 12 Jun 2023 18:10:34 +0000 (11:10 -0700)
committerDan Williams <dan.j.williams@intel.com>
Sun, 25 Jun 2023 21:54:51 +0000 (14:54 -0700)
commit0c36b6ad436a38b167af16e6c690c890b8b2df62
treebd72d99f338a3a05b50949e769be2ced8aa328f1
parent9968c9dd568e83f57fdc1f6127f8b369a0594991
cxl/mbox: Add sanitization handling machinery

Sanitization is by definition a device-monopolizing operation, and thus
the timeslicing rules for other background commands do not apply.
As such handle this special case asynchronously and return immediately.
Subsequent changes will allow completion to be pollable from userspace
via a sysfs file interface.

For devices that don't support interrupts for notifying background
command completion, self-poll with the caveat that the poller can
be out of sync with the ready hardware, and therefore care must be
taken to not allow any new commands to go through until the poller
sees the hw completion. The poller takes the mbox_mutex to stabilize
the flagging, minimizing any runtime overhead in the send path to
check for 'sanitize_tmo' for uncommon poll scenarios.

The irq case is much simpler as hardware will serialize/error
appropriately.

Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Davidlohr Bueso <dave@stgolabs.net>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Link: https://lore.kernel.org/r/20230612181038.14421-4-dave@stgolabs.net
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
drivers/cxl/core/memdev.c
drivers/cxl/cxlmem.h
drivers/cxl/pci.c