aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-04-07 19:20:40 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-04-07 19:20:40 -0400
commitd3436a1d03f9a416d8bedd968f16296e0140adcb (patch)
tree6809a3acc09cafafa4df0646154eb990eeccaab6
parent741f37b8ccf10b3f9976f7e55b703af8087f182a (diff)
parentc00bbcf8628969e103d4a7b351a53746f1025576 (diff)
Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
Pull virtio/qemu fixes from Michael S Tsirkin: "A couple of fixes for virtio and for the new QEMU fw cfg driver" * tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost: virtio: add VIRTIO_CONFIG_S_NEEDS_RESET device status bit MAINTAINERS: add entry for QEMU firmware: qemu_fw_cfg.c: hold ACPI global lock during device access virtio: virtio 1.0 cs04 spec compliance for reset qemu_fw_cfg: don't leak kobj on init error
-rw-r--r--MAINTAINERS7
-rw-r--r--drivers/firmware/qemu_fw_cfg.c24
-rw-r--r--drivers/virtio/virtio_pci_modern.c11
-rw-r--r--include/uapi/linux/virtio_config.h2
4 files changed, 40 insertions, 4 deletions
diff --git a/MAINTAINERS b/MAINTAINERS
index 40eb1dbe2ae5..d8c901bbec89 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -9142,6 +9142,13 @@ T: git git://github.com/KrasnikovEugene/wcn36xx.git
9142S: Supported 9142S: Supported
9143F: drivers/net/wireless/ath/wcn36xx/ 9143F: drivers/net/wireless/ath/wcn36xx/
9144 9144
9145QEMU MACHINE EMULATOR AND VIRTUALIZER SUPPORT
9146M: Gabriel Somlo <somlo@cmu.edu>
9147M: "Michael S. Tsirkin" <mst@redhat.com>
9148L: qemu-devel@nongnu.org
9149S: Maintained
9150F: drivers/firmware/qemu_fw_cfg.c
9151
9145RADOS BLOCK DEVICE (RBD) 9152RADOS BLOCK DEVICE (RBD)
9146M: Ilya Dryomov <idryomov@gmail.com> 9153M: Ilya Dryomov <idryomov@gmail.com>
9147M: Sage Weil <sage@redhat.com> 9154M: Sage Weil <sage@redhat.com>
diff --git a/drivers/firmware/qemu_fw_cfg.c b/drivers/firmware/qemu_fw_cfg.c
index fedbff55a7f3..815c4a5cae54 100644
--- a/drivers/firmware/qemu_fw_cfg.c
+++ b/drivers/firmware/qemu_fw_cfg.c
@@ -77,12 +77,28 @@ static inline u16 fw_cfg_sel_endianness(u16 key)
77static inline void fw_cfg_read_blob(u16 key, 77static inline void fw_cfg_read_blob(u16 key,
78 void *buf, loff_t pos, size_t count) 78 void *buf, loff_t pos, size_t count)
79{ 79{
80 u32 glk;
81 acpi_status status;
82
83 /* If we have ACPI, ensure mutual exclusion against any potential
84 * device access by the firmware, e.g. via AML methods:
85 */
86 status = acpi_acquire_global_lock(ACPI_WAIT_FOREVER, &glk);
87 if (ACPI_FAILURE(status) && status != AE_NOT_CONFIGURED) {
88 /* Should never get here */
89 WARN(1, "fw_cfg_read_blob: Failed to lock ACPI!\n");
90 memset(buf, 0, count);
91 return;
92 }
93
80 mutex_lock(&fw_cfg_dev_lock); 94 mutex_lock(&fw_cfg_dev_lock);
81 iowrite16(fw_cfg_sel_endianness(key), fw_cfg_reg_ctrl); 95 iowrite16(fw_cfg_sel_endianness(key), fw_cfg_reg_ctrl);
82 while (pos-- > 0) 96 while (pos-- > 0)
83 ioread8(fw_cfg_reg_data); 97 ioread8(fw_cfg_reg_data);
84 ioread8_rep(fw_cfg_reg_data, buf, count); 98 ioread8_rep(fw_cfg_reg_data, buf, count);
85 mutex_unlock(&fw_cfg_dev_lock); 99 mutex_unlock(&fw_cfg_dev_lock);
100
101 acpi_release_global_lock(glk);
86} 102}
87 103
88/* clean up fw_cfg device i/o */ 104/* clean up fw_cfg device i/o */
@@ -727,12 +743,18 @@ device_param_cb(mmio, &fw_cfg_cmdline_param_ops, NULL, S_IRUSR);
727 743
728static int __init fw_cfg_sysfs_init(void) 744static int __init fw_cfg_sysfs_init(void)
729{ 745{
746 int ret;
747
730 /* create /sys/firmware/qemu_fw_cfg/ top level directory */ 748 /* create /sys/firmware/qemu_fw_cfg/ top level directory */
731 fw_cfg_top_ko = kobject_create_and_add("qemu_fw_cfg", firmware_kobj); 749 fw_cfg_top_ko = kobject_create_and_add("qemu_fw_cfg", firmware_kobj);
732 if (!fw_cfg_top_ko) 750 if (!fw_cfg_top_ko)
733 return -ENOMEM; 751 return -ENOMEM;
734 752
735 return platform_driver_register(&fw_cfg_sysfs_driver); 753 ret = platform_driver_register(&fw_cfg_sysfs_driver);
754 if (ret)
755 fw_cfg_kobj_cleanup(fw_cfg_top_ko);
756
757 return ret;
736} 758}
737 759
738static void __exit fw_cfg_sysfs_exit(void) 760static void __exit fw_cfg_sysfs_exit(void)
diff --git a/drivers/virtio/virtio_pci_modern.c b/drivers/virtio/virtio_pci_modern.c
index f6f28cc7eb45..e76bd91a29da 100644
--- a/drivers/virtio/virtio_pci_modern.c
+++ b/drivers/virtio/virtio_pci_modern.c
@@ -17,6 +17,7 @@
17 * 17 *
18 */ 18 */
19 19
20#include <linux/delay.h>
20#define VIRTIO_PCI_NO_LEGACY 21#define VIRTIO_PCI_NO_LEGACY
21#include "virtio_pci_common.h" 22#include "virtio_pci_common.h"
22 23
@@ -271,9 +272,13 @@ static void vp_reset(struct virtio_device *vdev)
271 struct virtio_pci_device *vp_dev = to_vp_device(vdev); 272 struct virtio_pci_device *vp_dev = to_vp_device(vdev);
272 /* 0 status means a reset. */ 273 /* 0 status means a reset. */
273 vp_iowrite8(0, &vp_dev->common->device_status); 274 vp_iowrite8(0, &vp_dev->common->device_status);
274 /* Flush out the status write, and flush in device writes, 275 /* After writing 0 to device_status, the driver MUST wait for a read of
275 * including MSI-X interrupts, if any. */ 276 * device_status to return 0 before reinitializing the device.
276 vp_ioread8(&vp_dev->common->device_status); 277 * This will flush out the status write, and flush in device writes,
278 * including MSI-X interrupts, if any.
279 */
280 while (vp_ioread8(&vp_dev->common->device_status))
281 msleep(1);
277 /* Flush pending VQ/configuration callbacks. */ 282 /* Flush pending VQ/configuration callbacks. */
278 vp_synchronize_vectors(vdev); 283 vp_synchronize_vectors(vdev);
279} 284}
diff --git a/include/uapi/linux/virtio_config.h b/include/uapi/linux/virtio_config.h
index c18264df9504..4cb65bbfa654 100644
--- a/include/uapi/linux/virtio_config.h
+++ b/include/uapi/linux/virtio_config.h
@@ -40,6 +40,8 @@
40#define VIRTIO_CONFIG_S_DRIVER_OK 4 40#define VIRTIO_CONFIG_S_DRIVER_OK 4
41/* Driver has finished configuring features */ 41/* Driver has finished configuring features */
42#define VIRTIO_CONFIG_S_FEATURES_OK 8 42#define VIRTIO_CONFIG_S_FEATURES_OK 8
43/* Device entered invalid state, driver must reset it */
44#define VIRTIO_CONFIG_S_NEEDS_RESET 0x40
43/* We've given up on this device. */ 45/* We've given up on this device. */
44#define VIRTIO_CONFIG_S_FAILED 0x80 46#define VIRTIO_CONFIG_S_FAILED 0x80
45 47