Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1734842
| From | marcandre.lureau@redhat.com |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH v2 4/4] RFC: fw_cfg: add DMA write operation in sysfs |
| Date | 2017-09-19 14:00 +0200 |
| Message-ID | <urpm2-4YB-13@gated-at.bofh.it> (permalink) |
| References | <urpm2-4YB-11@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Since qemu 2.9, DMA write operations are allowed. However, usage of this
interface from kernel or user-space is strongly discouraged by the
maintainers. This patch is meant for experimentations for now.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
drivers/firmware/qemu_fw_cfg.c | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/drivers/firmware/qemu_fw_cfg.c b/drivers/firmware/qemu_fw_cfg.c
index 26152bfc7805..1ca3382e98df 100644
--- a/drivers/firmware/qemu_fw_cfg.c
+++ b/drivers/firmware/qemu_fw_cfg.c
@@ -524,9 +524,28 @@ static ssize_t fw_cfg_sysfs_read_raw(struct file *filp, struct kobject *kobj,
return fw_cfg_read_blob(entry->f.select, buf, pos, count, true);
}
+static ssize_t fw_cfg_sysfs_write_raw(struct file *filp, struct kobject *kobj,
+ struct bin_attribute *bin_attr,
+ char *buf, loff_t pos, size_t count)
+{
+ struct fw_cfg_sysfs_entry *entry = to_entry(kobj);
+
+ if (!fw_cfg_dma_enabled())
+ return -ENOTSUPP;
+
+ if (pos > entry->f.size)
+ return -EINVAL;
+
+ if (count > entry->f.size - pos)
+ count = entry->f.size - pos;
+
+ return fw_cfg_write_blob(entry->f.select, buf, pos, count);
+}
+
static struct bin_attribute fw_cfg_sysfs_attr_raw = {
- .attr = { .name = "raw", .mode = S_IRUSR },
+ .attr = { .name = "raw", .mode = S_IRUSR | S_IWUSR },
.read = fw_cfg_sysfs_read_raw,
+ .write = fw_cfg_sysfs_write_raw,
};
/*
--
2.14.1.146.gd35faa819
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v2 0/4] fw_cfg: add DMA operations & etc/vmcoreinfo support marcandre.lureau@redhat.com - 2017-09-19 14:00 +0200
[PATCH v2 1/4] fw_cfg: add DMA register marcandre.lureau@redhat.com - 2017-09-19 14:00 +0200
Re: [PATCH v2 1/4] fw_cfg: add DMA register kbuild test robot <lkp@intel.com> - 2017-09-22 13:10 +0200
[PATCH v2 4/4] RFC: fw_cfg: add DMA write operation in sysfs marcandre.lureau@redhat.com - 2017-09-19 14:00 +0200
[PATCH v2 2/4] fw_cfg: do DMA read operation marcandre.lureau@redhat.com - 2017-09-19 14:00 +0200
csiph-web