Skip to contentSkip to conversation

virtio: Virtio platform driver

PATCH In review Magnus Damm 3 participants 13 messages Mar 10, 2011 – Mar 17, 2011

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover virtio: Virtio platform driver

virtio: Virtio platform driver

[PATCH 01/02] virtio: Break out lguest virtio code to virtio_lguest.c [PATCH 02/02] virtio: Add virtio platform driver

These patches add a virtio platform driver to the Linux kernel. This platform driver has the same role as the virtio_pci driver, but instead of building on top of emulated PCI this driver is making use of the platform bus together with driver specific callbacks.

The virtio platform driver can be seen as a reusable implementation of the lguest virtio driver - in fact, most code is just taken directly from lguest_device.c and reworked to fit the platform device driver abstraction. The first patch breaks out code that can be shared between lguest and the virtio platform driver.

This code has been used to implement a mailbox interface between the two processor cores included in the sh7372 SoC. The sh7372 contains one ARM Cortex-A8 and one SH4AL-DSP core, and in the prototype two Linux kernels are running in parallel on the same chip. Virtio serves as a communication link between the two cores.

Tested on the SH architecture, but should work on any architecture.

---

 arch/x86/lguest/Kconfig          |    1 
 drivers/lguest/lguest_device.c   |  209 ----------------------------
 drivers/virtio/Kconfig           |   13 +
 drivers/virtio/Makefile          |    2 
 drivers/virtio/virtio_lguest.c   |  205 ++++++++++++++++++++++++++++
 drivers/virtio/virtio_platform.c |  282 +++++++++++++++++++++++++++++++++++++++
 include/linux/lguest.h           |    1 
 include/linux/lguest_device.h    |   46 ++++++
 include/linux/virtio_platform.h  |   12 +
 9 files changed, 564 insertions(+), 207 deletions(-)
#1 lore raw

PATCH 1/2 virtio: Break out lguest virtio code to virtio_lguest.c

From: Magnus Damm <[email protected]>

This patch breaks out code from lguest_device.c to the new file virtio_lguest.c. The new file is built when CONFIG_VIRTIO_LGUEST is selected. The x86 architecture is updated to select this kconfig variable in the case of lguest.

Needed by the virtio platform driver that shares configuration data structures with lguest.

---

 arch/x86/lguest/Kconfig        |    1 
 drivers/lguest/lguest_device.c |  209 ----------------------------------------
 drivers/virtio/Kconfig         |    2 
 drivers/virtio/Makefile        |    1 
 drivers/virtio/virtio_lguest.c |  205 +++++++++++++++++++++++++++++++++++++++
 include/linux/lguest.h         |    1 
 include/linux/lguest_device.h  |   46 ++++++++
 7 files changed, 258 insertions(+), 207 deletions(-)
arch/x86/lguest/Kconfig +1 -0
@@ -4,6 +4,7 @@ config LGUEST_GUEST
 	depends on X86_32
 	select VIRTUALIZATION
 	select VIRTIO
+	select VIRTIO_LGUEST
 	select VIRTIO_RING
 	select VIRTIO_CONSOLE
 	help
drivers/lguest/lguest_device.c +2 -207

233 lines not on this page · raw message

drivers/virtio/Kconfig +2 -0
@@ -33,3 +33,5 @@ config VIRTIO_BALLOON
 
 	 If unsure, say M.
 
+config VIRTIO_LGUEST
+	tristate
drivers/virtio/Makefile +1 -0
@@ -2,3 +2,4 @@ obj-$(CONFIG_VIRTIO) += virtio.o
 obj-$(CONFIG_VIRTIO_RING) += virtio_ring.o
 obj-$(CONFIG_VIRTIO_PCI) += virtio_pci.o
 obj-$(CONFIG_VIRTIO_BALLOON) += virtio_balloon.o
+obj-$(CONFIG_VIRTIO_LGUEST) += virtio_lguest.o
drivers/virtio/virtio_lguest.c new file +205 -0

205 lines not on this page · raw message

include/linux/lguest.h +1 -0
@@ -71,5 +71,6 @@ struct lguest_data {
 	unsigned int syscall_vec;
 };
 extern struct lguest_data lguest_data;
+
 #endif /* __ASSEMBLY__ */
 #endif	/* _LINUX_LGUEST_H */
include/linux/lguest_device.h new file +46 -0

46 lines not on this page · raw message

#2 lore raw

PATCH 1/2 virtio: Break out lguest virtio code to virtio_lguest.c

In reply to Magnus Damm

From: Magnus Damm <[email protected]>

This patch breaks out code from lguest_device.c to the new file virtio_lguest.c. The new file is built when CONFIG_VIRTIO_LGUEST is selected. The x86 architecture is updated to select this kconfig variable in the case of lguest.

Needed by the virtio platform driver that shares configuration data structures with lguest.

---

 arch/x86/lguest/Kconfig        |    1 
 drivers/lguest/lguest_device.c |  209 ----------------------------------------
 drivers/virtio/Kconfig         |    2 
 drivers/virtio/Makefile        |    1 
 drivers/virtio/virtio_lguest.c |  205 +++++++++++++++++++++++++++++++++++++++
 include/linux/lguest.h         |    1 
 include/linux/lguest_device.h  |   46 ++++++++
 7 files changed, 258 insertions(+), 207 deletions(-)
arch/x86/lguest/Kconfig +1 -0
@@ -4,6 +4,7 @@ config LGUEST_GUEST
 	depends on X86_32
 	select VIRTUALIZATION
 	select VIRTIO
+	select VIRTIO_LGUEST
 	select VIRTIO_RING
 	select VIRTIO_CONSOLE
 	help
drivers/lguest/lguest_device.c +2 -207

233 lines not on this page · raw message

drivers/virtio/Kconfig +2 -0
@@ -33,3 +33,5 @@ config VIRTIO_BALLOON
 
 	 If unsure, say M.
 
+config VIRTIO_LGUEST
+	tristate
drivers/virtio/Makefile +1 -0
@@ -2,3 +2,4 @@ obj-$(CONFIG_VIRTIO) += virtio.o
 obj-$(CONFIG_VIRTIO_RING) += virtio_ring.o
 obj-$(CONFIG_VIRTIO_PCI) += virtio_pci.o
 obj-$(CONFIG_VIRTIO_BALLOON) += virtio_balloon.o
+obj-$(CONFIG_VIRTIO_LGUEST) += virtio_lguest.o
drivers/virtio/virtio_lguest.c new file +205 -0

205 lines not on this page · raw message

include/linux/lguest.h +1 -0
@@ -71,5 +71,6 @@ struct lguest_data {
 	unsigned int syscall_vec;
 };
 extern struct lguest_data lguest_data;
+
 #endif /* __ASSEMBLY__ */
 #endif	/* _LINUX_LGUEST_H */
include/linux/lguest_device.h new file +46 -0

46 lines not on this page · raw message

#3 lore raw

PATCH 2/2 virtio: Add virtio platform driver

In reply to Magnus Damm

From: Magnus Damm <[email protected]>

This patch adds a virtio platform driver. The code is based on the lguest implementation available in drivers/lguest/lguest_device.c

The iomem resource is used to point out the lguest device descriptor, and the platform data contains two separate callbacks for notification.

---

 drivers/virtio/Kconfig           |   11 +
 drivers/virtio/Makefile          |    1 
 drivers/virtio/virtio_platform.c |  282 ++++++++++++++++++++++++++++++++++++++
 include/linux/virtio_platform.h  |   12 +
 4 files changed, 306 insertions(+)
drivers/virtio/Kconfig +11 -0
@@ -35,3 +35,14 @@ config VIRTIO_BALLOON
 
 config VIRTIO_LGUEST
 	tristate
+
+config VIRTIO_PLATFORM
+	tristate "Platform driver for virtio devices (EXPERIMENTAL)"
+	select VIRTIO
+	select VIRTIO_RING
+	select VIRTIO_LGUEST
+	---help---
+	 This drivers provides support for virtio based paravirtual device
+	 drivers over a platform bus.
+
+	 If unsure, say N.
drivers/virtio/Makefile +1 -0
@@ -3,3 +3,4 @@ obj-$(CONFIG_VIRTIO_RING) += virtio_ring
 obj-$(CONFIG_VIRTIO_PCI) += virtio_pci.o
 obj-$(CONFIG_VIRTIO_BALLOON) += virtio_balloon.o
 obj-$(CONFIG_VIRTIO_LGUEST) += virtio_lguest.o
+obj-$(CONFIG_VIRTIO_PLATFORM) += virtio_platform.o
drivers/virtio/virtio_platform.c new file +282 -0

282 lines not on this page · raw message

include/linux/virtio_platform.h new file +12 -0
@@ -0,0 +1,12 @@
+#ifndef _LINUX_VIRTIO_PLATFORM_H
+#define _LINUX_VIRTIO_PLATFORM_H
+#include <linux/platform_device.h>
+#include <linux/lguest_launcher.h>
+
+struct virtio_platform_data {
+	void (*notify_virtio)(struct platform_device *pdev);
+	void (*notify_virtqueue)(struct platform_device *pdev,
+				 struct lguest_vqconfig *config);
+};
+
+#endif /* _LINUX_VIRTIO_PLATFORM_H */
#4 lore raw

PATCH 2/2 virtio: Add virtio platform driver

In reply to Magnus Damm

From: Magnus Damm <[email protected]>

This patch adds a virtio platform driver. The code is based on the lguest implementation available in drivers/lguest/lguest_device.c

The iomem resource is used to point out the lguest device descriptor, and the platform data contains two separate callbacks for notification.

---

 drivers/virtio/Kconfig           |   11 +
 drivers/virtio/Makefile          |    1 
 drivers/virtio/virtio_platform.c |  282 ++++++++++++++++++++++++++++++++++++++
 include/linux/virtio_platform.h  |   12 +
 4 files changed, 306 insertions(+)
drivers/virtio/Kconfig +11 -0
@@ -35,3 +35,14 @@ config VIRTIO_BALLOON
 
 config VIRTIO_LGUEST
 	tristate
+
+config VIRTIO_PLATFORM
+	tristate "Platform driver for virtio devices (EXPERIMENTAL)"
+	select VIRTIO
+	select VIRTIO_RING
+	select VIRTIO_LGUEST
+	---help---
+	 This drivers provides support for virtio based paravirtual device
+	 drivers over a platform bus.
+
+	 If unsure, say N.
drivers/virtio/Makefile +1 -0
@@ -3,3 +3,4 @@ obj-$(CONFIG_VIRTIO_RING) += virtio_ring
 obj-$(CONFIG_VIRTIO_PCI) += virtio_pci.o
 obj-$(CONFIG_VIRTIO_BALLOON) += virtio_balloon.o
 obj-$(CONFIG_VIRTIO_LGUEST) += virtio_lguest.o
+obj-$(CONFIG_VIRTIO_PLATFORM) += virtio_platform.o
drivers/virtio/virtio_platform.c new file +282 -0

282 lines not on this page · raw message

include/linux/virtio_platform.h new file +12 -0
@@ -0,0 +1,12 @@
+#ifndef _LINUX_VIRTIO_PLATFORM_H
+#define _LINUX_VIRTIO_PLATFORM_H
+#include <linux/platform_device.h>
+#include <linux/lguest_launcher.h>
+
+struct virtio_platform_data {
+	void (*notify_virtio)(struct platform_device *pdev);
+	void (*notify_virtqueue)(struct platform_device *pdev,
+				 struct lguest_vqconfig *config);
+};
+
+#endif /* _LINUX_VIRTIO_PLATFORM_H */
#5 lore raw
In reply to Magnus Damm
Quoted 4 lines · Magnus Damm

virtio: Virtio platform driver

[PATCH 01/02] virtio: Break out lguest virtio code to virtio_lguest.c [PATCH 02/02] virtio: Add virtio platform driver

I have no problem with these patches, but it's just churn until we see your actual drivers.

The S/390 devs might be interested, as their bus is very similar too...

Cheers,
Rusty.

#6 lore raw
In reply to Magnus Damm
Quoted 4 lines · Magnus Damm

virtio: Virtio platform driver

[PATCH 01/02] virtio: Break out lguest virtio code to virtio_lguest.c [PATCH 02/02] virtio: Add virtio platform driver

I have no problem with these patches, but it's just churn until we see your actual drivers.

The S/390 devs might be interested, as their bus is very similar too...

Cheers,
Rusty.

#7 lore raw

Hi Rusty,

Quoted 8 lines · Rusty Russell
Quoted 4 lines · Magnus Damm

virtio: Virtio platform driver

[PATCH 01/02] virtio: Break out lguest virtio code to virtio_lguest.c [PATCH 02/02] virtio: Add virtio platform driver

I have no problem with these patches, but it's just churn until we see your actual drivers.

Well, actually this platform driver is used together with already existing drivers, so there are no new virtio drivers to wait for.

The drivers that have been tested are so far:

CONFIG_VIRTIO_CONSOLE=y
CONFIG_VIRTIO_NET=y

At this point there are four different pieces of code working together

1) Virtio platform driver patches (for guest)
2) SH4AL-DSP guest kernel patch
3) ARM UIO driver patches (for host)
4) User space backing code for ARM based on lguest.c

These patches in this mail thread are 1), and I decided to brush up that portion and submit upstream because it's the part that is easiest to break out. I intend to post the rest bit by bit over time, but if someone is interested then I can post everything at once too.

Quoted 1 line

The S/390 devs might be interested, as their bus is very similar too...

The lguest device code is very similar as well, perhaps it's worth refactoring that a bit to build on top of the platform driver. Not sure if you see that as a move in the right direction though.

Thanks for your feedback!

/ magnus

#8 lore raw
Quoted 27 lines · Magnus Damm

Hi Rusty,

Quoted 8 lines · Rusty Russell
Quoted 4 lines · Magnus Damm

virtio: Virtio platform driver

[PATCH 01/02] virtio: Break out lguest virtio code to virtio_lguest.c [PATCH 02/02] virtio: Add virtio platform driver

I have no problem with these patches, but it's just churn until we see your actual drivers.

Well, actually this platform driver is used together with already existing drivers, so there are no new virtio drivers to wait for.

The drivers that have been tested are so far:

CONFIG_VIRTIO_CONSOLE=y
CONFIG_VIRTIO_NET=y

At this point there are four different pieces of code working together

1) Virtio platform driver patches (for guest)
2) SH4AL-DSP guest kernel patch
3) ARM UIO driver patches (for host)
4) User space backing code for ARM based on lguest.c

Quoted 5 lines

These patches in this mail thread are 1), and I decided to brush up that portion and submit upstream because it's the part that is easiest to break out. I intend to post the rest bit by bit over time, but if someone is interested then I can post everything at once too.

I'm very interested in the full series of patches. I want to do something similar to talk between two Linux kernels (x86 and PowerPC) connected by a PCI bus.

Thanks,
Ira

Quoted 13 lines
Quoted 1 line

The S/390 devs might be interested, as their bus is very similar too...

The lguest device code is very similar as well, perhaps it's worth refactoring that a bit to build on top of the platform driver. Not sure if you see that as a move in the right direction though.

Thanks for your feedback!

/ magnus
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/virtualization

#9 lore raw
Quoted 32 lines · Ira W. Snyder
Quoted 25 lines · Magnus Damm
Quoted 8 lines · Rusty Russell
Quoted 4 lines · Magnus Damm

virtio: Virtio platform driver

[PATCH 01/02] virtio: Break out lguest virtio code to virtio_lguest.c [PATCH 02/02] virtio: Add virtio platform driver

I have no problem with these patches, but it's just churn until we see your actual drivers.

Well, actually this platform driver is used together with already existing drivers, so there are no new virtio drivers to wait for.

The drivers that have been tested are so far:

CONFIG_VIRTIO_CONSOLE=y
CONFIG_VIRTIO_NET=y

At this point there are four different pieces of code working together

1) Virtio platform driver patches (for guest)
2) SH4AL-DSP guest kernel patch
3) ARM UIO driver patches (for host)
4) User space backing code for ARM based on lguest.c

Quoted 5 lines

These patches in this mail thread are 1), and I decided to brush up that portion and submit upstream because it's the part that is easiest to break out. I intend to post the rest bit by bit over time, but if someone is interested then I can post everything at once too.

Quoted 3 lines

I'm very interested in the full series of patches. I want to do something similar to talk between two Linux kernels (x86 and PowerPC) connected by a PCI bus.

For a full source release, have a look at SH Core Linux 20110317:
http://www.spinics.net/lists/linux-sh/msg07188.html

The SH kernel patch shows how to make use of the virtio platform driver.

Cheers,

/ magnus

#10 lore raw
In reply to Ira W. Snyder
Quoted 32 lines · Ira W. Snyder
Quoted 25 lines · Magnus Damm
Quoted 8 lines · Rusty Russell
Quoted 4 lines · Magnus Damm

virtio: Virtio platform driver

[PATCH 01/02] virtio: Break out lguest virtio code to virtio_lguest.c [PATCH 02/02] virtio: Add virtio platform driver

I have no problem with these patches, but it's just churn until we see your actual drivers.

Well, actually this platform driver is used together with already existing drivers, so there are no new virtio drivers to wait for.

The drivers that have been tested are so far:

CONFIG_VIRTIO_CONSOLE=y
CONFIG_VIRTIO_NET=y

At this point there are four different pieces of code working together

1) Virtio platform driver patches (for guest)
2) SH4AL-DSP guest kernel patch
3) ARM UIO driver patches (for host)
4) User space backing code for ARM based on lguest.c

Quoted 5 lines

These patches in this mail thread are 1), and I decided to brush up that portion and submit upstream because it's the part that is easiest to break out. I intend to post the rest bit by bit over time, but if someone is interested then I can post everything at once too.

Quoted 3 lines

I'm very interested in the full series of patches. I want to do something similar to talk between two Linux kernels (x86 and PowerPC) connected by a PCI bus.

For a full source release, have a look at SH Core Linux 20110317:
http://www.spinics.net/lists/linux-sh/msg07188.html

The SH kernel patch shows how to make use of the virtio platform driver.

Cheers,

/ magnus

#11 lore raw
In reply to Magnus Damm
Quoted 27 lines · Magnus Damm

Hi Rusty,

Quoted 8 lines · Rusty Russell
Quoted 4 lines · Magnus Damm

virtio: Virtio platform driver

[PATCH 01/02] virtio: Break out lguest virtio code to virtio_lguest.c [PATCH 02/02] virtio: Add virtio platform driver

I have no problem with these patches, but it's just churn until we see your actual drivers.

Well, actually this platform driver is used together with already existing drivers, so there are no new virtio drivers to wait for.

The drivers that have been tested are so far:

CONFIG_VIRTIO_CONSOLE=y
CONFIG_VIRTIO_NET=y

At this point there are four different pieces of code working together

1) Virtio platform driver patches (for guest)
2) SH4AL-DSP guest kernel patch
3) ARM UIO driver patches (for host)
4) User space backing code for ARM based on lguest.c

Quoted 5 lines

These patches in this mail thread are 1), and I decided to brush up that portion and submit upstream because it's the part that is easiest to break out. I intend to post the rest bit by bit over time, but if someone is interested then I can post everything at once too.

I'm very interested in the full series of patches. I want to do something similar to talk between two Linux kernels (x86 and PowerPC) connected by a PCI bus.

Thanks,
Ira

Quoted 13 lines
Quoted 1 line

The S/390 devs might be interested, as their bus is very similar too...

The lguest device code is very similar as well, perhaps it's worth refactoring that a bit to build on top of the platform driver. Not sure if you see that as a move in the right direction though.

Thanks for your feedback!

/ magnus
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/virtualization

#12 lore raw
In reply to Rusty Russell

Hi Rusty,

Quoted 8 lines · Rusty Russell
Quoted 4 lines · Magnus Damm

virtio: Virtio platform driver

[PATCH 01/02] virtio: Break out lguest virtio code to virtio_lguest.c [PATCH 02/02] virtio: Add virtio platform driver

I have no problem with these patches, but it's just churn until we see your actual drivers.

Well, actually this platform driver is used together with already existing drivers, so there are no new virtio drivers to wait for.

The drivers that have been tested are so far:

CONFIG_VIRTIO_CONSOLE=y
CONFIG_VIRTIO_NET=y

At this point there are four different pieces of code working together

1) Virtio platform driver patches (for guest)
2) SH4AL-DSP guest kernel patch
3) ARM UIO driver patches (for host)
4) User space backing code for ARM based on lguest.c

These patches in this mail thread are 1), and I decided to brush up that portion and submit upstream because it's the part that is easiest to break out. I intend to post the rest bit by bit over time, but if someone is interested then I can post everything at once too.

Quoted 1 line

The S/390 devs might be interested, as their bus is very similar too...

The lguest device code is very similar as well, perhaps it's worth refactoring that a bit to build on top of the platform driver. Not sure if you see that as a move in the right direction though.

Thanks for your feedback!

/ magnus