Using Virtio-gpio in guest VM


shibi590268@...
 

Hello,
         I need to use two gpio pins from a VM. 
I used    -s 10,virtio-gpio,@gpiochip0{11=pin0:12=pin1} \ in the launch scripts. The kernel boots up successfully with a new pci device added 00:0a.0 PIC: Intel Corporation Device 8609.

The device is getting listed as PIC: Intel Corporation Device 8609 is this correct?
But i couldn't find the gpio device listed under /dev/
ls /dev/gpio
ls: cannot access '/dev/gpio': No such file or directory

or in /sys/class/gpio

ls /sys/class/gpio/
export  unexport

ls /sys/bus/gpio/devices/
ubunturt@ubunturt-Standard-PC-i440FX-PIIX-1996:~$

I couldn't find virtio-gpio module in kernel. So I used a patch from https://lkml.iu.edu/hypermail/linux/kernel/2108.1/01975.html. But still i am not successful in this. 
Is there anything that i am missing? Is there any patch recommendation available that could be used.

User VM: ubuntu
Service VM : ubuntu
I am using ACRN hypervisor: v2.8
 
 


Liu, Fuzhong
 

Hi

Is following kernel config enabled in your User VM?

CONFIG_VIRTIO_GPIO=y

 

Please share the kernel config and dmesg log of User VM.

 

Thanks!

 

BR.

Fuzhong

 

From: acrn-users@... <acrn-users@...> On Behalf Of shibi590268@...
Sent: Friday, April 29, 2022 9:30 PM
To: acrn-users@...
Subject: [acrn-users] Using Virtio-gpio in guest VM

 

Hello,
         I need to use two gpio pins from a VM. 
I used    -s 10,virtio-gpio,@gpiochip0{11=pin0:12=pin1} \ in the launch scripts. The kernel boots up successfully with a new pci device added 00:0a.0 PIC: Intel Corporation Device 8609.

The device is getting listed as PIC: Intel Corporation Device 8609 is this correct?

But i couldn't find the gpio device listed under /dev/

ls /dev/gpio

ls: cannot access '/dev/gpio': No such file or directory


or in /sys/class/gpio

ls /sys/class/gpio/

export  unexport

ls /sys/bus/gpio/devices/

ubunturt@ubunturt-Standard-PC-i440FX-PIIX-1996:~$

I couldn't find virtio-gpio module in kernel. So I used a patch from https://lkml.iu.edu/hypermail/linux/kernel/2108.1/01975.html. But still i am not successful in this. 
Is there anything that i am missing? Is there any patch recommendation available that could be used.

User VM: ubuntu
Service VM : ubuntu
I am using ACRN hypervisor: v2.8

 

 


shibi590268@...
 

Hi
   I am using the ACRN patched rt kernel from https://github.com/projectacrn/acrn-kernel.git with 5.10/prempt-rt branch to use it in RTVM. I am unable to locate CONFIG_VIRTIO_GPIO=Y in the config. Is there any separate patch available for this?

Attached is the .config file
 


Geoffroy Van Cutsem
 

I don’t see this anywhere in the 5.10 version, while it was there in the 4.19/preempt-rt. I suspect that means it’s a driver that was never upstreamed (or is still in the process of being upstreamed).

 

Is using the 4.19 kernel an option for you?

 

Does anyone from the kernel team know if there is a version of that driver for the 5.10 preempt-rt kernel?

 

Thanks,

Geoffroy

 

 

From: acrn-users@... <acrn-users@...> On Behalf Of shibi590268@...
Sent: Monday, May 2, 2022 9:44 am
To: acrn-users@...
Subject: Re: [acrn-users] Using Virtio-gpio in guest VM

 

Hi
   I am using the ACRN patched rt kernel from https://github.com/projectacrn/acrn-kernel.git with 5.10/prempt-rt branch to use it in RTVM. I am unable to locate CONFIG_VIRTIO_GPIO=Y in the config. Is there any separate patch available for this?

Attached is the .config file
 


shibi590268@...
 

Hi 
   I want to use little latest kernel. Do you mean this driver gpio-virtio.c. Is following the config that you are pointing to? 

config GPIO_VIRTIO
  tristate "GPIO virtio-based front-end driver"
  depends on X86 && PCI && VIRTIO_PCI
  help
  This module implements GPIO emulation over virtio transport.
   
  Say Y or M here to build GPIO virtio front-end driver.
   
  If the driver is built as a module, it will be called gpio-virtio.


Geoffroy Van Cutsem
 

Yes, that’s the driver in question. I do not know if we have a version of it for the latest kernel, let’s see what the kernel team has to say about it.

 

Geoffroy

 

From: acrn-users@... <acrn-users@...> On Behalf Of shibi590268@...
Sent: Monday, May 2, 2022 1:09 pm
To: acrn-users@...
Subject: Re: [acrn-users] Using Virtio-gpio in guest VM

 

Hi 
   I want to use little latest kernel. Do you mean this driver gpio-virtio.c. Is following the config that you are pointing to? 

config GPIO_VIRTIO

 

 

 

tristate "GPIO virtio-based front-end driver"

 

 

 

depends on X86 && PCI && VIRTIO_PCI

 

 

 

help

 

 

 

This module implements GPIO emulation over virtio transport.

 

 

 

 

 

 

 

Say Y or M here to build GPIO virtio front-end driver.

 

 

 

 

 

 

 

If the driver is built as a module, it will be called gpio-virtio.

 

 


shibi590268@...
 

Could someone please reply and help me


shibi590268@...
 

Is CONFIG_VIRTIO_IOMMU needed for using GPIO_VIRTIO in guest VM?


shibi590268@...
 

Hi Geoffroy,
      I checked in the latest version of kernels(i.e., 5.18) which included the driver in question. I compiled the kernel with CONFIG_GPIO_VIRTIO=y. I see the same behavior as before. The virtio-gpio gets emulated as a PCI device.
Should there be some examples or some references that was used while evaluating the virtio gpio, please share that. Thanks in Advance


Liu, Fuzhong
 

Hi

Please share the kernel config and dmesg log of User VM which included the driver.

 

Thanks!

 

BR.

Fuzhong

 

 

From: acrn-users@... <acrn-users@...> On Behalf Of shibi590268@...
Sent: Saturday, May 7, 2022 9:57 AM
To: acrn-users@...
Subject: Re: [acrn-users] Using Virtio-gpio in guest VM

 

Hi Geoffroy,
      I checked in the latest version of kernels(i.e., 5.18) which included the driver in question. I compiled the kernel with CONFIG_GPIO_VIRTIO=y. I see the same behavior as before. The virtio-gpio gets emulated as a PCI device.
Should there be some examples or some references that was used while evaluating the virtio gpio, please share that. Thanks in Advance


shibi590268@...
 

Please find the attachments. config, dmesg and lspci.


Liu, Fuzhong
 

Please share lspci -xxxxvvvv

 

BR.

Fuzhong

 

From: acrn-users@... <acrn-users@...> On Behalf Of shibi590268@...
Sent: Monday, May 9, 2022 4:43 PM
To: acrn-users@...
Subject: Re: [acrn-users] Using Virtio-gpio in guest VM

 

Please find the attachments. config, dmesg and lspci.


shibi590268@...
 

On Mon, May 9, 2022 at 02:43 PM, Liu, Fuzhong wrote:
lspci -xxxxvvvv

attached lspci info


Liu, Fuzhong
 

Hi

Checked with ACRN expert, following ACRN virtio devices work well with V1.4; but not maintained  any more.

devicemodel/include/virtio.h

 

* ACRN virtio device IDs

*/

#define VIRTIO_DEV_RPMB         0x8601

#define VIRTIO_DEV_HECI         0x8602

#define VIRTIO_DEV_AUDIO        0x8603

#define VIRTIO_DEV_IPU          0x8604

#define VIRTIO_DEV_TSN          0x8605

#define VIRTIO_DEV_HYPERDMABUF  0x8606

#define VIRTIO_DEV_HDCP         0x8607

#define VIRTIO_DEV_COREU        0x8608

#define VIRTIO_DEV_GPIO         0x8609

#define VIRTIO_DEV_I2C          0x860a

 

 

https://github.com/projectacrn/acrn-hypervisor/tree/release_1.4/

https://github.com/projectacrn/acrn-kernel/tree/release_1.4

 

BR.

Fuzhong

From: acrn-users@... <acrn-users@...> On Behalf Of shibi590268@...
Sent: Monday, May 9, 2022 6:06 PM
To: acrn-users@...
Subject: Re: [acrn-users] Using Virtio-gpio in guest VM

 

On Mon, May 9, 2022 at 02:43 PM, Liu, Fuzhong wrote:

lspci -xxxxvvvv


attached lspci info


shibi590268@...
 
Edited

Is it? But v1.4 is pretty old right. Would there be any impact on the performance of we go for this release version?

I could find the same macros present in the master branch.
Please let me understand what is the difference between them as far as virtio gpio is concerned.
Is there any possibility that virtio gpio be supported in future releases?


shibi590268@...
 

Fuzhong,
       I checked the acrn kernel with tag release_1.4. That seems to work with latest acrn hypervisor tag release_2.7. Hence i patched the code to the latest kernel 5.10/preempt-rt and it worked. Consider this as my suggestion it would be good if the virtio-gpio patch is carried over to the latest kernels in the future.