Re: [PATCH v11 2/4] fw_cfg: do DMA read operation

From: Michael S. Tsirkin
Date: Thu Feb 01 2018 - 21:48:13 EST


On Thu, Feb 01, 2018 at 02:02:58PM +0100, Marc-André Lureau wrote:
> Modify fw_cfg_read_blob() to use DMA if the device supports it.
> Return errors, because the operation may fail.
>
> The DMA operation is expected to run synchronously with today qemu,
> but the specification states that it may become async, so we run
> "control" field check in a loop for eventual changes.
>
> We may want to switch all the *buf addresses to use only kmalloc'ed
> buffers (instead of using stack/image addresses with dma=false).
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx>

This seems to cause no end of pain. I see no reason to keep
pushing this patch until it's all much more stable.

Something like the below would disable it temporarily.


commit 05054fca8b96900f6b54ab0056458f92b616d74c
Author: Michael S. Tsirkin <mst@xxxxxxxxxx>
Date: Fri Feb 2 04:29:59 2018 +0200

fixup! fw_cfg: do DMA read operation

diff --git a/drivers/firmware/qemu_fw_cfg.c b/drivers/firmware/qemu_fw_cfg.c
index d86ad92..33e0256 100644
--- a/drivers/firmware/qemu_fw_cfg.c
+++ b/drivers/firmware/qemu_fw_cfg.c
@@ -41,6 +41,9 @@ MODULE_AUTHOR("Gabriel L. Somlo <somlo@xxxxxxx>");
MODULE_DESCRIPTION("QEMU fw_cfg sysfs support");
MODULE_LICENSE("GPL");

+/* enable DMA for all accesses */
+#define FW_CFG_DMA_READ_ENABLE 0
+
/* selector key values for "well-known" fw_cfg entries */
#define FW_CFG_SIGNATURE 0x00
#define FW_CFG_ID 0x01
@@ -171,7 +174,7 @@ static ssize_t fw_cfg_read_blob(struct device *dev, u16 key,
}

mutex_lock(&fw_cfg_dev_lock);
- if (dma && fw_cfg_dma_enabled()) {
+ if (FW_CFG_DMA_READ_ENABLE && dma && fw_cfg_dma_enabled()) {
if (pos == 0) {
ret = fw_cfg_dma_transfer(dev, buf, count, key << 16
| FW_CFG_DMA_CTL_SELECT