Skip to contentSkip to conversation

drivers: platform: goldfish: fix the checkpatch complain in Kconfig

PATCH In review [email protected] 2 participants 12 messages Jan 9, 2019 – Jan 31, 2019

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/3 drivers: platform: goldfish: fix the checkpatch complain in Kconfig

From: Roman Kiryanov <[email protected]>

prefer 'help' over '---help---' for new help texts

---
Changes in v3:
- No changes.

Changes in v2:
- New change, a minor cleanup.

 drivers/platform/goldfish/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/platform/goldfish/Kconfig +2 -2
index 479031aa4f88..74fdfa68d1f2 100644
@@ -2,7 +2,7 @@ menuconfig GOLDFISH
 	bool "Platform support for Goldfish virtual devices"
 	depends on X86_32 || X86_64 || ARM || ARM64 || MIPS
 	depends on HAS_IOMEM
-	---help---
+	help
 	  Say Y here to get to see options for the Goldfish virtual platform.
 	  This option alone does not add any kernel code.
 
@@ -12,7 +12,7 @@ if GOLDFISH
 
 config GOLDFISH_PIPE
 	tristate "Goldfish virtual device for QEMU pipes"
-	---help---
+	help
 	  This is a virtual device to drive the QEMU pipe interface used by
 	  the Goldfish Android Virtual Device.
 
Signature · 1 line
2.20.1.97.g81188d93c3-goog
#1 lore raw

PATCH v3 2/3 drivers: platform: goldfish: goldfish_address_space: add a driver

From: Roman Kiryanov <[email protected]>

A driver for the Goldfish Android emulator that occupies address space to use it with the memory sharing device on the QEMU side. The memory sharding device allocates subranges and populate them with actual RAM. This allows sharing host's memory with the guest.

---
Changes in v3:
- No changes.

Changes in v2:
- Removed WARN_ON.
- Moved to drivers/platform/goldfish (from drivers/misc).

 drivers/platform/goldfish/Kconfig             |   9 +
 drivers/platform/goldfish/Makefile            |   1 +
 .../goldfish/goldfish_address_space.c         | 666 ++++++++++++++++++
 .../linux/goldfish/goldfish_address_space.h   |  27 +
 4 files changed, 703 insertions(+)
 create mode 100644 drivers/platform/goldfish/goldfish_address_space.c
 create mode 100644 include/uapi/linux/goldfish/goldfish_address_space.h
drivers/platform/goldfish/Kconfig +9 -0
index 74fdfa68d1f2..60ecec4a3c59 100644
@@ -16,4 +16,13 @@ config GOLDFISH_PIPE
 	  This is a virtual device to drive the QEMU pipe interface used by
 	  the Goldfish Android Virtual Device.
 
+config GOLDFISH_ADDRESS_SPACE
+	tristate "A Goldfish driver that talks to the memory sharing device in QEMU"
+	depends on PCI
+	depends on GOLDFISH
+	help
+	  A Goldfish driver that allocates address space ranges in the guest to
+	  populate them later in the host. This allows sharing host's memory
+	  with the guest.
+
 endif # GOLDFISH
drivers/platform/goldfish/Makefile +1 -0
index e0c202df9674..034abe0727b8 100644
@@ -2,3 +2,4 @@
 # Makefile for Goldfish platform specific drivers
 #
 obj-$(CONFIG_GOLDFISH_PIPE)	+= goldfish_pipe.o
+obj-$(CONFIG_GOLDFISH_ADDRESS_SPACE) += goldfish_address_space.o
drivers/platform/goldfish/goldfish_address_space.c new file +666 -0

666 lines not on this page · raw message

include/uapi/linux/goldfish/goldfish_address_space.h new file +27 -0
new file mode 100644
index 000000000000..b1d11f95a4e1
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef UAPI_GOLDFISH_ADDRESS_SPACE_H
+#define UAPI_GOLDFISH_ADDRESS_SPACE_H
+
+#include <linux/types.h>
+
+#define GOLDFISH_ADDRESS_SPACE_DEVICE_NAME	"goldfish_address_space"
+
+struct goldfish_address_space_allocate_block {
+	__u64 size;
+	__u64 offset;
+	__u64 phys_addr;
+};
+
+#define GOLDFISH_ADDRESS_SPACE_IOCTL_MAGIC	'G'
+
+#define GOLDFISH_ADDRESS_SPACE_IOCTL_OP(OP, T)	\
+	_IOWR(GOLDFISH_ADDRESS_SPACE_IOCTL_MAGIC, OP, T)
+
+#define GOLDFISH_ADDRESS_SPACE_IOCTL_ALLOCATE_BLOCK \
+	GOLDFISH_ADDRESS_SPACE_IOCTL_OP(10, \
+		struct goldfish_address_space_allocate_block)
+
+#define GOLDFISH_ADDRESS_SPACE_IOCTL_DEALLOCATE_BLOCK \
+	GOLDFISH_ADDRESS_SPACE_IOCTL_OP(11, __u64)
+
+#endif /* UAPI_GOLDFISH_ADDRESS_SPACE_H */
Signature · 1 line
2.20.1.97.g81188d93c3-goog
#2 lore raw

Re: [PATCH v3 2/3] drivers: platform: goldfish: goldfish_address_space: add a driver

Quoted 8 lines · On Tue, Jan 08, 2019 at 06:11:11PM -0800, [email protected] wrote:

From: Roman Kiryanov <[email protected]>

A driver for the Goldfish Android emulator that occupies address space to use it with the memory sharing device on the QEMU side. The memory sharding device allocates subranges and populate them with actual RAM. This allows sharing host's memory with the guest.

Do you have a pointer to the QEMU commit that matches up with the device that this driver is supposed to be supporting? That would help in trying to review the code to determine exactly what this driver is doing and why the existing memory driver does not work well enough for you (hint, you didn't say why you need this...)

thanks,

greg k-h

#4 lore raw

Re: [PATCH v3 2/3] drivers: platform: goldfish: goldfish_address_space: add a driver

Quoted 6 lines
Quoted 2 lines

Do you have a pointer to the QEMU commit that matches up with the device that this driver is supposed to be supporting?

The device code is here:

https://android.googlesource.com/platform/external/qemu/+/emu-master-dev/hw/pci/goldfish_address_space.c

Hi Greg, do you need anything else to review my patch?

Quoted 1 line

why the existing memory driver does not work well enough for you

I tried to find the existing driver to share memory between QEMU and a linux guest but could not find one.

#5 lore raw

Re: [PATCH v3 2/3] drivers: platform: goldfish: goldfish_address_space: add a driver

In reply to [email protected]
Quoted 31 lines · On Tue, Jan 08, 2019 at 06:11:11PM -0800, [email protected] wrote:

From: Roman Kiryanov <[email protected]>

A driver for the Goldfish Android emulator that occupies address space to use it with the memory sharing device on the QEMU side. The memory sharding device allocates subranges and populate them with actual RAM. This allows sharing host's memory with the guest.

---
Changes in v3:
- No changes.

Changes in v2:
- Removed WARN_ON.
- Moved to drivers/platform/goldfish (from drivers/misc).

 drivers/platform/goldfish/Kconfig             |   9 +
 drivers/platform/goldfish/Makefile            |   1 +
 .../goldfish/goldfish_address_space.c         | 666 ++++++++++++++++++
 .../linux/goldfish/goldfish_address_space.h   |  27 +
 4 files changed, 703 insertions(+)
 create mode 100644 drivers/platform/goldfish/goldfish_address_space.c
 create mode 100644 include/uapi/linux/goldfish/goldfish_address_space.h
drivers/platform/goldfish/Kconfig +0 -0
index 74fdfa68d1f2..60ecec4a3c59 100644
@@ -16,4 +16,13 @@ config GOLDFISH_PIPE
 	  This is a virtual device to drive the QEMU pipe interface used by

drivers/platform/goldfish/Kconfig config GOLDFISH_PIPE · line 26

Quoted 10 lines
drivers/platform/goldfish/Kconfig +8 -0
 	  the Goldfish Android Virtual Device.
 
+config GOLDFISH_ADDRESS_SPACE
+	tristate "A Goldfish driver that talks to the memory sharing device in QEMU"
+	depends on PCI
+	depends on GOLDFISH
+	help
+	  A Goldfish driver that allocates address space ranges in the guest to
+	  populate them later in the host. This allows sharing host's memory
+	  with the guest.

How does QEMU do this today? There isn't a virtio or some other virtual memory device that allows memory regions to be shared? I can't believe that there isn't one yet. If not, then this should be some kind of "generic" QEMU memory device, not a "goldfish" specific one, right?

Please work with the QEMU developers on this, I need their ack before I can take something like this.

thanks,

greg k-h

#6 lore raw

Re: [PATCH v3 2/3] drivers: platform: goldfish: goldfish_address_space: add a driver

Quoted 4 lines

How does QEMU do this today? There isn't a virtio or some other virtual memory device that allows memory regions to be shared? I can't believe that there isn't one yet. If not, then this should be some kind of "generic" QEMU memory device, not a "goldfish" specific one, right?

I also thought this should not be something unique to us. So I asked in our internal mailing list, I heard nothing back.

Quoted 2 lines

Please work with the QEMU developers on this, I need their ack before I can take something like this.

This is a good point. I asked there (nothing since 1/24):

http://lists.nongnu.org/archive/html/qemu-discuss/2019-01/msg00055.html

When we were working on our device side, we had to change some QEMU code and later noticed that HAXM also requires some fixes (we had meetings with Intel). I suppose QEMU does not have this feature yet.

Could you please tell if we can proceed with upstreaming as is?

Regards,
Roman.

#7 lore raw

Re: [PATCH v3 2/3] drivers: platform: goldfish: goldfish_address_space: add a driver

Quoted 7 lines · Roman Kiryanov
Quoted 4 lines

How does QEMU do this today? There isn't a virtio or some other virtual memory device that allows memory regions to be shared? I can't believe that there isn't one yet. If not, then this should be some kind of "generic" QEMU memory device, not a "goldfish" specific one, right?

I also thought this should not be something unique to us. So I asked in our internal mailing list, I heard nothing back.

As we have no idea who is on your internal mailing list, that's really not a good representation :)

Quoted 6 lines
Quoted 2 lines

Please work with the QEMU developers on this, I need their ack before I can take something like this.

This is a good point. I asked there (nothing since 1/24):

http://lists.nongnu.org/archive/html/qemu-discuss/2019-01/msg00055.html

less than a week is short :)

Quoted 5 lines

When we were working on our device side, we had to change some QEMU code and later noticed that HAXM also requires some fixes (we had meetings with Intel). I suppose QEMU does not have this feature yet.

Could you please tell if we can proceed with upstreaming as is?

I told you what the requirements would be to get this merged in the previous email, that has not changed.

thanks,

greg k-h

#8 lore raw

Re: [PATCH v3 2/3] drivers: platform: goldfish: goldfish_address_space: add a driver

In reply to Roman Kiryanov
Quoted 13 lines · Roman Kiryanov
Quoted 4 lines

How does QEMU do this today? There isn't a virtio or some other virtual memory device that allows memory regions to be shared? I can't believe that there isn't one yet. If not, then this should be some kind of "generic" QEMU memory device, not a "goldfish" specific one, right?

I also thought this should not be something unique to us. So I asked in our internal mailing list, I heard nothing back.

Quoted 2 lines

Please work with the QEMU developers on this, I need their ack before I can take something like this.

This is a good point. I asked there (nothing since 1/24):

Quoted 7 lines

http://lists.nongnu.org/archive/html/qemu-discuss/2019-01/msg00055.html

When we were working on our device side, we had to change some QEMU code and later noticed that HAXM also requires some fixes (we had meetings with Intel). I suppose QEMU does not have this feature yet.

Could you please tell if we can proceed with upstreaming as is?

Also, why does the other Android "emulator", cuttlefish, not need special drivers like this and the other goldfish drivers? Shouldn't you be using the same interfaces that they use that are already merged upstream?

Actually, now that cuttlefish works on a mainline kernel, can't we just delete the existing goldfish code?

thanks,

greg k-h

#9 lore raw

Re: [PATCH v3 2/3] drivers: platform: goldfish: goldfish_address_space: add a driver

Quoted 6 lines

Also, why does the other Android "emulator", cuttlefish, not need special drivers like this and the other goldfish drivers? Shouldn't you be using the same interfaces that they use that are already merged upstream?
Actually, now that cuttlefish works on a mainline kernel, can't we just delete the existing goldfish code?

cuttlefish is a separate emulator with different assumptions which do not work for us.

Our emulator runs on Linux, Mac and Windows, it uses host's GPU directly for rendering.

I am not sure how cuttlefish accesses host's GPU memory (it might not support this),
but we need it to support coherent memory access for Vulcan. We also might use it to access
host's camera pixels to avoid copying them.

Please keep goldfish drivers.

#10 lore raw

PATCH v3 3/3 drivers: platform: goldfish: goldfish_sync: add a driver

In reply to [email protected]

From: Roman Kiryanov <[email protected]>

The Goldfish sync driver is designed to provide a interface between the underlying host's sync device and the kernel's fence sync framework.

---
Changes in v3:
- Removed WARN_ON.

Changes in v2:
- Added a missing include (mod_devicetable.h).
- Put in one batch with goldfish_address_space.c to avoid merge comflicts.

 drivers/platform/goldfish/Kconfig           |   7 +
 drivers/platform/goldfish/Makefile          |   1 +
 drivers/platform/goldfish/goldfish_sync.c   | 827 ++++++++++++++++++++
 include/uapi/linux/goldfish/goldfish_sync.h |  28 +
 4 files changed, 863 insertions(+)
 create mode 100644 drivers/platform/goldfish/goldfish_sync.c
 create mode 100644 include/uapi/linux/goldfish/goldfish_sync.h
drivers/platform/goldfish/Kconfig +7 -0
index 60ecec4a3c59..841250235430 100644
@@ -25,4 +25,11 @@ config GOLDFISH_ADDRESS_SPACE
 	  populate them later in the host. This allows sharing host's memory
 	  with the guest.
 
+config GOLDFISH_SYNC
+	tristate "Goldfish AVD Sync Driver"
+	depends on SW_SYNC
+	depends on SYNC_FILE
+	help
+	  Emulated sync fences for the Goldfish Android Virtual Device.
+
 endif # GOLDFISH
drivers/platform/goldfish/Makefile +1 -0
index 034abe0727b8..bdff4d6a0ad9 100644
@@ -3,3 +3,4 @@
 #
 obj-$(CONFIG_GOLDFISH_PIPE)	+= goldfish_pipe.o
 obj-$(CONFIG_GOLDFISH_ADDRESS_SPACE) += goldfish_address_space.o
+obj-$(CONFIG_GOLDFISH_SYNC)	+= goldfish_sync.o
drivers/platform/goldfish/goldfish_sync.c new file +827 -0

827 lines not on this page · raw message

include/uapi/linux/goldfish/goldfish_sync.h new file +28 -0
new file mode 100644
index 000000000000..01d762f77308
@@ -0,0 +1,28 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef UAPI_GOLDFISH_SYNC_H
+#define UAPI_GOLDFISH_SYNC_H
+
+#include <linux/types.h>
+
+#define GOLDFISH_SYNC_DEVICE_NAME "goldfish_sync"
+
+struct goldfish_sync_ioctl_info {
+	__u64 host_glsync_handle_in;
+	__u64 host_syncthread_handle_in;
+	__s32 fence_fd_out;
+};
+
+/* There is an ioctl associated with goldfish sync driver.
+ * Make it conflict with ioctls that are not likely to be used
+ * in the emulator.
+ *
+ * '@'	00-0F	linux/radeonfb.h		conflict!
+ * '@'	00-0F	drivers/video/aty/aty128fb.c	conflict!
+ */
+#define GOLDFISH_SYNC_IOC_MAGIC	'@'
+
+#define GOLDFISH_SYNC_IOC_QUEUE_WORK	\
+	_IOWR(GOLDFISH_SYNC_IOC_MAGIC, 0, struct goldfish_sync_ioctl_info)
+
+#endif /* UAPI_GOLDFISH_SYNC_H */
Signature · 1 line
2.20.1.97.g81188d93c3-goog
#11 lore raw

Re: [PATCH v3 3/3] drivers: platform: goldfish: goldfish_sync: add a driver

Quoted 15 lines · On Tue, Jan 08, 2019 at 06:11:12PM -0800, [email protected] wrote:

From: Roman Kiryanov <[email protected]>

The Goldfish sync driver is designed to provide a interface between the underlying host's sync device and the kernel's fence sync framework.

---
Changes in v3:
- Removed WARN_ON.

Changes in v2:
- Added a missing include (mod_devicetable.h).
- Put in one batch with goldfish_address_space.c to avoid merge comflicts.

Quoted 8 lines
 drivers/platform/goldfish/Kconfig           |   7 +
 drivers/platform/goldfish/Makefile          |   1 +
 drivers/platform/goldfish/goldfish_sync.c   | 827 ++++++++++++++++++++
 include/uapi/linux/goldfish/goldfish_sync.h |  28 +
 4 files changed, 863 insertions(+)
 create mode 100644 drivers/platform/goldfish/goldfish_sync.c
 create mode 100644 include/uapi/linux/goldfish/goldfish_sync.h

Please get this reviewed by the sync subsystem maintainers to ensure that you are using the API properly, and that this really is needed. If it is needed, why is this a goldfish-only type device, why do not all systems need this?

thanks,

greg k-h