hw/cxl/mbox: replace sanitize_running() with cxl_dev_media_disabled()
authorHyeonggon Yoo <42.hyeyoo@gmail.com>
Fri, 5 Jul 2024 12:06:41 +0000 (13:06 +0100)
committerMichael S. Tsirkin <mst@redhat.com>
Sun, 21 Jul 2024 18:31:59 +0000 (14:31 -0400)
commit75b800dd3bd8042503ddd4e8a4169f34349325e2
tree740d1e313adc53b13c5ab157325915ed3246e711
parentd61cc5b6a8d373376a8bf5ec29cfc3267a29efbe
hw/cxl/mbox: replace sanitize_running() with cxl_dev_media_disabled()

The spec states that reads/writes should have no effect and a part of
commands should be ignored when the media is disabled, not when the
sanitize command is running.

Introduce cxl_dev_media_disabled() to check if the media is disabled and
replace sanitize_running() with it.

Make sure that the media has been correctly disabled during sanitation
by adding an assert to __toggle_media(). Now, enabling when already
enabled or vice versa results in an assert() failure.

Suggested-by: Davidlohr Bueso <dave@stgolabs.net>
Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com>
Link: https://lore.kernel.org/r/20231222090051.3265307-4-42.hyeyoo@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Message-Id: <20240705120643.959422-3-Jonathan.Cameron@huawei.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
hw/cxl/cxl-mailbox-utils.c
hw/mem/cxl_type3.c
include/hw/cxl/cxl_device.h