linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V4 0/5] virtio: Add virtio-device bindings
@ 2021-07-27  5:23 Viresh Kumar
  2021-07-27  5:23 ` [PATCH V4 3/5] dt-bindings: gpio: Add bindings for gpio-virtio Viresh Kumar
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Viresh Kumar @ 2021-07-27  5:23 UTC (permalink / raw)
  To: Jason Wang, Michael S. Tsirkin, Rob Herring, Arnd Bergmann,
	Jean-Philippe Brucker, Bartosz Golaszewski, Linus Walleij,
	Viresh Kumar
  Cc: Vincent Guittot, Bill Mills, Alex Bennée,
	Enrico Weigelt, metux IT consult, Jie Deng, devicetree,
	linux-kernel, virtualization, Arnd Bergmann, linux-gpio,
	linux-i2c, Wolfram Sang

Hi,

Currently the DT only provides support for following node types for virtio-mmio
nodes:

        virtio_mmio@a000000 {
                dma-coherent;
                interrupts = <0x00 0x10 0x01>;
                reg = <0x00 0xa000000 0x00 0x200>;
                compatible = "virtio,mmio";
        };

Here, each virtio-mmio corresponds to a virtio-device. But there is no way for
other users in the DT to show their dependency on virtio devices.

This patchset provides that support.

The first patch adds virtio-device bindings to allow for device sub-nodes to be
present and the second patch updates the virtio core to update the of_node.

Other patches add bindings for i2c and gpio devices.

Tested on x86 with qemu for arm64.

V3->V4:
- The binding is named "virtio,deviceXXXXXXXX" now.
- The virtio binding doesn't restrict the node names anymore.
- The i2c/gpio nodes are named i2c and gpio now.
- Dropped including gpio.yaml.
- Updated code to match the new binding name.
- Use "type: object" in additional-property.

V2/2.1->V3:
- Added review-tags from Arnd and Wolfram.
- Only the 5th patch changed otherwise:
  - Use of_device_is_compatible() instead of keeping a list of devices.
  - Use snprintf (with BUG_ON on return value) to create the compatible string,
    whose length is fixed using "virtio,XXXXXXXX".
  - Use dev_of_node().

V1->V2:
- The changes (both binding and code) are made at virtio level, instead of
  virtio-mmio. This allows the same to be used by all device types, irrespective
  of the transport mechanism.

- Dropped the reg property and used compatible in the form "virtio,<DID>".

- Dropped dt-bindings/virtio/virtio_ids.h.

- Add a patch to sync virtio-ids from spec, required for the last patch.

--
Viresh

Viresh Kumar (5):
  dt-bindings: virtio: Add binding for virtio devices
  dt-bindings: i2c: Add bindings for i2c-virtio
  dt-bindings: gpio: Add bindings for gpio-virtio
  uapi: virtio_ids: Sync ids with specification
  virtio: Bind virtio device to device-tree node

 .../devicetree/bindings/gpio/gpio-virtio.yaml | 59 +++++++++++++++++++
 .../devicetree/bindings/i2c/i2c-virtio.yaml   | 51 ++++++++++++++++
 .../devicetree/bindings/virtio/mmio.yaml      |  3 +-
 .../bindings/virtio/virtio-device.yaml        | 41 +++++++++++++
 drivers/virtio/virtio.c                       | 57 +++++++++++++++++-
 include/uapi/linux/virtio_ids.h               | 12 ++++
 6 files changed, 219 insertions(+), 4 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/gpio/gpio-virtio.yaml
 create mode 100644 Documentation/devicetree/bindings/i2c/i2c-virtio.yaml
 create mode 100644 Documentation/devicetree/bindings/virtio/virtio-device.yaml

-- 
2.31.1.272.g89b43f80a514


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH V4 3/5] dt-bindings: gpio: Add bindings for gpio-virtio
  2021-07-27  5:23 [PATCH V4 0/5] virtio: Add virtio-device bindings Viresh Kumar
@ 2021-07-27  5:23 ` Viresh Kumar
  2021-08-02 19:40   ` Rob Herring
  2021-08-04  3:56 ` [PATCH V4 0/5] virtio: Add virtio-device bindings Viresh Kumar
  2021-08-31  5:31 ` Viresh Kumar
  2 siblings, 1 reply; 10+ messages in thread
From: Viresh Kumar @ 2021-07-27  5:23 UTC (permalink / raw)
  To: Jason Wang, Michael S. Tsirkin, Rob Herring, Arnd Bergmann,
	Jean-Philippe Brucker, Linus Walleij, Bartosz Golaszewski,
	Viresh Kumar
  Cc: Vincent Guittot, Bill Mills, Alex Bennée,
	Enrico Weigelt, metux IT consult, Jie Deng, devicetree,
	linux-kernel, virtualization, Arnd Bergmann, linux-gpio

This patch adds binding for virtio GPIO controller, it is based on
virtio-device bindings.

Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 .../devicetree/bindings/gpio/gpio-virtio.yaml | 59 +++++++++++++++++++
 1 file changed, 59 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/gpio/gpio-virtio.yaml

diff --git a/Documentation/devicetree/bindings/gpio/gpio-virtio.yaml b/Documentation/devicetree/bindings/gpio/gpio-virtio.yaml
new file mode 100644
index 000000000000..601d85754577
--- /dev/null
+++ b/Documentation/devicetree/bindings/gpio/gpio-virtio.yaml
@@ -0,0 +1,59 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/gpio/gpio-virtio.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Virtio GPIO controller
+
+maintainers:
+  - Viresh Kumar <viresh.kumar@linaro.org>
+
+allOf:
+  - $ref: /schemas/virtio/virtio-device.yaml#
+
+description:
+  Virtio GPIO controller, see /schemas/virtio/virtio-device.yaml for more
+  details.
+
+properties:
+  $nodename:
+    const: gpio
+
+  compatible:
+    const: virtio,device29
+
+  gpio-controller: true
+
+  "#gpio-cells":
+    const: 2
+
+  interrupt-controller: true
+
+  "#interrupt-cells":
+    const: 2
+
+required:
+  - compatible
+  - gpio-controller
+  - "#gpio-cells"
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    virtio@3000 {
+        compatible = "virtio,mmio";
+        reg = <0x3000 0x100>;
+        interrupts = <41>;
+
+        gpio {
+            compatible = "virtio,device29";
+            gpio-controller;
+            #gpio-cells = <2>;
+            interrupt-controller;
+            #interrupt-cells = <2>;
+        };
+    };
+
+...
-- 
2.31.1.272.g89b43f80a514


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH V4 3/5] dt-bindings: gpio: Add bindings for gpio-virtio
  2021-07-27  5:23 ` [PATCH V4 3/5] dt-bindings: gpio: Add bindings for gpio-virtio Viresh Kumar
@ 2021-08-02 19:40   ` Rob Herring
  2021-08-03  4:30     ` Viresh Kumar
  0 siblings, 1 reply; 10+ messages in thread
From: Rob Herring @ 2021-08-02 19:40 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: Jason Wang, Michael S. Tsirkin, Arnd Bergmann,
	Jean-Philippe Brucker, Linus Walleij, Bartosz Golaszewski,
	Vincent Guittot, Bill Mills, Alex Bennée,
	Enrico Weigelt, metux IT consult, Jie Deng, devicetree,
	linux-kernel, virtualization, Arnd Bergmann, linux-gpio

On Tue, Jul 27, 2021 at 10:53:50AM +0530, Viresh Kumar wrote:
> This patch adds binding for virtio GPIO controller, it is based on
> virtio-device bindings.
> 
> Reviewed-by: Arnd Bergmann <arnd@arndb.de>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
>  .../devicetree/bindings/gpio/gpio-virtio.yaml | 59 +++++++++++++++++++
>  1 file changed, 59 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/gpio/gpio-virtio.yaml
> 
> diff --git a/Documentation/devicetree/bindings/gpio/gpio-virtio.yaml b/Documentation/devicetree/bindings/gpio/gpio-virtio.yaml
> new file mode 100644
> index 000000000000..601d85754577
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/gpio/gpio-virtio.yaml
> @@ -0,0 +1,59 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/gpio/gpio-virtio.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Virtio GPIO controller
> +
> +maintainers:
> +  - Viresh Kumar <viresh.kumar@linaro.org>
> +
> +allOf:
> +  - $ref: /schemas/virtio/virtio-device.yaml#
> +
> +description:
> +  Virtio GPIO controller, see /schemas/virtio/virtio-device.yaml for more
> +  details.
> +
> +properties:
> +  $nodename:
> +    const: gpio
> +
> +  compatible:
> +    const: virtio,device29
> +
> +  gpio-controller: true
> +
> +  "#gpio-cells":
> +    const: 2
> +
> +  interrupt-controller: true
> +
> +  "#interrupt-cells":
> +    const: 2

Humm, how does one implement interrupts without a parent interrupt? It 
uses the parent virtio,mmio interrupt?

> +
> +required:
> +  - compatible
> +  - gpio-controller
> +  - "#gpio-cells"
> +
> +unevaluatedProperties: false
> +
> +examples:
> +  - |
> +    virtio@3000 {
> +        compatible = "virtio,mmio";
> +        reg = <0x3000 0x100>;
> +        interrupts = <41>;
> +
> +        gpio {
> +            compatible = "virtio,device29";
> +            gpio-controller;
> +            #gpio-cells = <2>;
> +            interrupt-controller;
> +            #interrupt-cells = <2>;
> +        };
> +    };
> +
> +...
> -- 
> 2.31.1.272.g89b43f80a514
> 
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH V4 3/5] dt-bindings: gpio: Add bindings for gpio-virtio
  2021-08-02 19:40   ` Rob Herring
@ 2021-08-03  4:30     ` Viresh Kumar
  2021-08-03 15:47       ` Rob Herring
  0 siblings, 1 reply; 10+ messages in thread
From: Viresh Kumar @ 2021-08-03  4:30 UTC (permalink / raw)
  To: Rob Herring
  Cc: Jason Wang, Michael S. Tsirkin, Arnd Bergmann,
	Jean-Philippe Brucker, Linus Walleij, Bartosz Golaszewski,
	Vincent Guittot, Bill Mills, Alex Bennée,
	Enrico Weigelt, metux IT consult, Jie Deng, devicetree,
	linux-kernel, virtualization, Arnd Bergmann, linux-gpio

On 02-08-21, 13:40, Rob Herring wrote:
> Humm, how does one implement interrupts without a parent interrupt? It 
> uses the parent virtio,mmio interrupt?

Kind of, yeah, but not necessarily.

The interrupt information is passed over buffers shared between host and guest.
Now the guest may process the buffers when it receives a notification from the
host, that will be at downpath of an interrupt for virtio,mmio. Or the guest may
poll on the virtqueue and process any buffers as soon as they are made
available, no interrupts then.

-- 
viresh

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH V4 3/5] dt-bindings: gpio: Add bindings for gpio-virtio
  2021-08-03  4:30     ` Viresh Kumar
@ 2021-08-03 15:47       ` Rob Herring
  2021-08-04  3:49         ` Viresh Kumar
  0 siblings, 1 reply; 10+ messages in thread
From: Rob Herring @ 2021-08-03 15:47 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: Jason Wang, Michael S. Tsirkin, Arnd Bergmann,
	Jean-Philippe Brucker, Linus Walleij, Bartosz Golaszewski,
	Vincent Guittot, Bill Mills, Alex Bennée,
	Enrico Weigelt, metux IT consult, Jie Deng, devicetree,
	linux-kernel@vger.kernel.org,
	open list:DRM DRIVER FOR QEMU'S CIRRUS DEVICE, Arnd Bergmann,
	open list:GPIO SUBSYSTEM

n Mon, Aug 2, 2021 at 10:30 PM Viresh Kumar <viresh.kumar@linaro.org> wrote:
>
> On 02-08-21, 13:40, Rob Herring wrote:
> > Humm, how does one implement interrupts without a parent interrupt? It
> > uses the parent virtio,mmio interrupt?
>
> Kind of, yeah, but not necessarily.
>
> The interrupt information is passed over buffers shared between host and guest.
> Now the guest may process the buffers when it receives a notification from the
> host, that will be at downpath of an interrupt for virtio,mmio. Or the guest may
> poll on the virtqueue and process any buffers as soon as they are made
> available, no interrupts then.

Okay, thanks for the explanation.

Reviewed-by: Rob Herring <robh@kernel.org>

Rob

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH V4 3/5] dt-bindings: gpio: Add bindings for gpio-virtio
  2021-08-03 15:47       ` Rob Herring
@ 2021-08-04  3:49         ` Viresh Kumar
  0 siblings, 0 replies; 10+ messages in thread
From: Viresh Kumar @ 2021-08-04  3:49 UTC (permalink / raw)
  To: Rob Herring
  Cc: Jason Wang, Michael S. Tsirkin, Arnd Bergmann,
	Jean-Philippe Brucker, Linus Walleij, Bartosz Golaszewski,
	Vincent Guittot, Bill Mills, Alex Bennée,
	Enrico Weigelt, metux IT consult, Jie Deng, devicetree,
	linux-kernel@vger.kernel.org,
	open list:DRM DRIVER FOR QEMU'S CIRRUS DEVICE, Arnd Bergmann,
	open list:GPIO SUBSYSTEM

On 03-08-21, 09:47, Rob Herring wrote:
> n Mon, Aug 2, 2021 at 10:30 PM Viresh Kumar <viresh.kumar@linaro.org> wrote:
> >
> > On 02-08-21, 13:40, Rob Herring wrote:
> > > Humm, how does one implement interrupts without a parent interrupt? It
> > > uses the parent virtio,mmio interrupt?
> >
> > Kind of, yeah, but not necessarily.
> >
> > The interrupt information is passed over buffers shared between host and guest.
> > Now the guest may process the buffers when it receives a notification from the
> > host, that will be at downpath of an interrupt for virtio,mmio. Or the guest may
> > poll on the virtqueue and process any buffers as soon as they are made
> > available, no interrupts then.
> 
> Okay, thanks for the explanation.
> 
> Reviewed-by: Rob Herring <robh@kernel.org>

Thanks for reviewing this Rob.

-- 
viresh

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH V4 0/5] virtio: Add virtio-device bindings
  2021-07-27  5:23 [PATCH V4 0/5] virtio: Add virtio-device bindings Viresh Kumar
  2021-07-27  5:23 ` [PATCH V4 3/5] dt-bindings: gpio: Add bindings for gpio-virtio Viresh Kumar
@ 2021-08-04  3:56 ` Viresh Kumar
  2021-08-11  5:38   ` Viresh Kumar
  2021-08-31  5:31 ` Viresh Kumar
  2 siblings, 1 reply; 10+ messages in thread
From: Viresh Kumar @ 2021-08-04  3:56 UTC (permalink / raw)
  To: Jason Wang, Michael S. Tsirkin, Rob Herring, Arnd Bergmann,
	Jean-Philippe Brucker, Bartosz Golaszewski, Linus Walleij
  Cc: Vincent Guittot, Bill Mills, Alex Bennée,
	Enrico Weigelt, metux IT consult, Jie Deng, devicetree,
	linux-kernel, virtualization, Arnd Bergmann, linux-gpio,
	linux-i2c, Wolfram Sang

On 27-07-21, 10:53, Viresh Kumar wrote:
> Hi,
> 
> Currently the DT only provides support for following node types for virtio-mmio
> nodes:
> 
>         virtio_mmio@a000000 {
>                 dma-coherent;
>                 interrupts = <0x00 0x10 0x01>;
>                 reg = <0x00 0xa000000 0x00 0x200>;
>                 compatible = "virtio,mmio";
>         };
> 
> Here, each virtio-mmio corresponds to a virtio-device. But there is no way for
> other users in the DT to show their dependency on virtio devices.
> 
> This patchset provides that support.
> 
> The first patch adds virtio-device bindings to allow for device sub-nodes to be
> present and the second patch updates the virtio core to update the of_node.
> 
> Other patches add bindings for i2c and gpio devices.
> 
> Tested on x86 with qemu for arm64.

Michael,

I hope you will be picking this series (Now that it is reviewed by
others) ? Just so you know, Wolfram needs the 4th patch, 4/5, to base
the virtio-i2c driver over it and has requested an immutable branch
for the same.

Thanks.

-- 
viresh

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH V4 0/5] virtio: Add virtio-device bindings
  2021-08-04  3:56 ` [PATCH V4 0/5] virtio: Add virtio-device bindings Viresh Kumar
@ 2021-08-11  5:38   ` Viresh Kumar
  0 siblings, 0 replies; 10+ messages in thread
From: Viresh Kumar @ 2021-08-11  5:38 UTC (permalink / raw)
  To: Jason Wang, Michael S. Tsirkin, Rob Herring, Arnd Bergmann,
	Jean-Philippe Brucker, Bartosz Golaszewski, Linus Walleij
  Cc: Vincent Guittot, Bill Mills, Alex Bennée,
	Enrico Weigelt, metux IT consult, Jie Deng, devicetree,
	linux-kernel, virtualization, Arnd Bergmann, linux-gpio,
	linux-i2c, Wolfram Sang

On 04-08-21, 09:26, Viresh Kumar wrote:
> Michael,
> 
> I hope you will be picking this series (Now that it is reviewed by
> others) ? Just so you know, Wolfram needs the 4th patch, 4/5, to base
> the virtio-i2c driver over it and has requested an immutable branch
> for the same.

Michael, we need an immutable branch with the following patch:

  uapi: virtio_ids: Sync ids with specification

This will enable Wolfram to apply the I2C driver for 5.15-rc1 and
maybe Linus as well for the GPIO driver.

-- 
viresh

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH V4 0/5] virtio: Add virtio-device bindings
  2021-07-27  5:23 [PATCH V4 0/5] virtio: Add virtio-device bindings Viresh Kumar
  2021-07-27  5:23 ` [PATCH V4 3/5] dt-bindings: gpio: Add bindings for gpio-virtio Viresh Kumar
  2021-08-04  3:56 ` [PATCH V4 0/5] virtio: Add virtio-device bindings Viresh Kumar
@ 2021-08-31  5:31 ` Viresh Kumar
  2021-08-31 14:25   ` Michael S. Tsirkin
  2 siblings, 1 reply; 10+ messages in thread
From: Viresh Kumar @ 2021-08-31  5:31 UTC (permalink / raw)
  To: Jason Wang, Michael S. Tsirkin, Rob Herring, Arnd Bergmann,
	Jean-Philippe Brucker, Bartosz Golaszewski, Linus Walleij
  Cc: Vincent Guittot, Bill Mills, Alex Bennée,
	Enrico Weigelt, metux IT consult, Jie Deng, devicetree,
	linux-kernel, virtualization, Arnd Bergmann, linux-gpio,
	linux-i2c, Wolfram Sang

On 27-07-21, 10:53, Viresh Kumar wrote:
> Hi,
> 
> Currently the DT only provides support for following node types for virtio-mmio
> nodes:
> 
>         virtio_mmio@a000000 {
>                 dma-coherent;
>                 interrupts = <0x00 0x10 0x01>;
>                 reg = <0x00 0xa000000 0x00 0x200>;
>                 compatible = "virtio,mmio";
>         };
> 
> Here, each virtio-mmio corresponds to a virtio-device. But there is no way for
> other users in the DT to show their dependency on virtio devices.
> 
> This patchset provides that support.
> 
> The first patch adds virtio-device bindings to allow for device sub-nodes to be
> present and the second patch updates the virtio core to update the of_node.
> 
> Other patches add bindings for i2c and gpio devices.
> 
> Tested on x86 with qemu for arm64.

Michael, are you picking these up for 5.15 ?

-- 
viresh

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH V4 0/5] virtio: Add virtio-device bindings
  2021-08-31  5:31 ` Viresh Kumar
@ 2021-08-31 14:25   ` Michael S. Tsirkin
  0 siblings, 0 replies; 10+ messages in thread
From: Michael S. Tsirkin @ 2021-08-31 14:25 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: Jason Wang, Rob Herring, Arnd Bergmann, Jean-Philippe Brucker,
	Bartosz Golaszewski, Linus Walleij, Vincent Guittot, Bill Mills,
	Alex Bennée, Enrico Weigelt, metux IT consult, Jie Deng,
	devicetree, linux-kernel, virtualization, Arnd Bergmann,
	linux-gpio, linux-i2c, Wolfram Sang

On Tue, Aug 31, 2021 at 11:01:05AM +0530, Viresh Kumar wrote:
> On 27-07-21, 10:53, Viresh Kumar wrote:
> > Hi,
> > 
> > Currently the DT only provides support for following node types for virtio-mmio
> > nodes:
> > 
> >         virtio_mmio@a000000 {
> >                 dma-coherent;
> >                 interrupts = <0x00 0x10 0x01>;
> >                 reg = <0x00 0xa000000 0x00 0x200>;
> >                 compatible = "virtio,mmio";
> >         };
> > 
> > Here, each virtio-mmio corresponds to a virtio-device. But there is no way for
> > other users in the DT to show their dependency on virtio devices.
> > 
> > This patchset provides that support.
> > 
> > The first patch adds virtio-device bindings to allow for device sub-nodes to be
> > present and the second patch updates the virtio core to update the of_node.
> > 
> > Other patches add bindings for i2c and gpio devices.
> > 
> > Tested on x86 with qemu for arm64.
> 
> Michael, are you picking these up for 5.15 ?

Okay.

> -- 
> viresh


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-08-31 14:25 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-07-27  5:23 [PATCH V4 0/5] virtio: Add virtio-device bindings Viresh Kumar
2021-07-27  5:23 ` [PATCH V4 3/5] dt-bindings: gpio: Add bindings for gpio-virtio Viresh Kumar
2021-08-02 19:40   ` Rob Herring
2021-08-03  4:30     ` Viresh Kumar
2021-08-03 15:47       ` Rob Herring
2021-08-04  3:49         ` Viresh Kumar
2021-08-04  3:56 ` [PATCH V4 0/5] virtio: Add virtio-device bindings Viresh Kumar
2021-08-11  5:38   ` Viresh Kumar
2021-08-31  5:31 ` Viresh Kumar
2021-08-31 14:25   ` Michael S. Tsirkin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).