All of lore.kernel.org
 help / color / mirror / Atom feed
* Access I2C bus from guest/DomU on ARM board
@ 2018-01-16 13:39 Saumya Rajesh
  2018-01-16 14:46 ` Lars Kurth
  2018-01-16 15:52 ` Andrii Anisov
  0 siblings, 2 replies; 9+ messages in thread
From: Saumya Rajesh @ 2018-01-16 13:39 UTC (permalink / raw)
  To: xen-devel, xen-users


[-- Attachment #1.1: Type: text/plain, Size: 550 bytes --]

Hi Xen community


I have built and brought up Xen 4.8 on Renesas RCar H3. For a specific
requirement, I need to use the I2C bus of the board from Domain U. Is there
a way to use the I2C bus from the guest?
I have looked into para-virtualization and passthrough [1][2] but there
isn't enough support or resources related to I2C bus sharing on ARM. Any
possible idea would be appreciated.

Regards
Saumya

[1]
https://lists.xenproject.org/archives/html/xen-users/2017-10/msg00019.html
[2] https://wiki.xenproject.org/wiki/File:DriverDomainonARM01.pdf

[-- Attachment #1.2: Type: text/html, Size: 4141 bytes --]

[-- Attachment #2: Type: text/plain, Size: 157 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: Access I2C bus from guest/DomU on ARM board
  2018-01-16 13:39 Access I2C bus from guest/DomU on ARM board Saumya Rajesh
@ 2018-01-16 14:46 ` Lars Kurth
  2018-01-16 15:52 ` Andrii Anisov
  1 sibling, 0 replies; 9+ messages in thread
From: Lars Kurth @ 2018-01-16 14:46 UTC (permalink / raw)
  To: Saumya Rajesh; +Cc: xen-devel, embedded-pv-devel, xen-users


[-- Attachment #1.1: Type: text/plain, Size: 1029 bytes --]

Added embedded-pv-devel@lists.xenproject.org

> On 16 Jan 2018, at 13:39, Saumya Rajesh <saumyarajesh93@gmail.com> wrote:
> 
> Hi Xen community
> 
> I have built and brought up Xen 4.8 on Renesas RCar H3. For a specific requirement, I need to use the I2C bus of the board from Domain U. Is there a way to use the I2C bus from the guest?
> I have looked into para-virtualization and passthrough [1][2] but there isn't enough support or resources related to I2C bus sharing on ARM. Any possible idea would be appreciated.
> 
> Regards
> Saumya
> 
> [1] https://lists.xenproject.org/archives/html/xen-users/2017-10/msg00019.html <https://lists.xenproject.org/archives/html/xen-users/2017-10/msg00019.html>
> [2] https://wiki.xenproject.org/wiki/File:DriverDomainonARM01.pdf <https://wiki.xenproject.org/wiki/File:DriverDomainonARM01.pdf>
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xenproject.org
> https://lists.xenproject.org/mailman/listinfo/xen-devel


[-- Attachment #1.2: Type: text/html, Size: 5205 bytes --]

[-- Attachment #2: Type: text/plain, Size: 157 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: Access I2C bus from guest/DomU on ARM board
  2018-01-16 13:39 Access I2C bus from guest/DomU on ARM board Saumya Rajesh
  2018-01-16 14:46 ` Lars Kurth
@ 2018-01-16 15:52 ` Andrii Anisov
  2018-01-17 14:03   ` Saumya Rajesh
  1 sibling, 1 reply; 9+ messages in thread
From: Andrii Anisov @ 2018-01-16 15:52 UTC (permalink / raw)
  To: Saumya Rajesh, xen-devel, xen-users

Dear Rajesh,


You can try to get an I2C bus controller in DomU in PIO mode following 
[1], keeping in mind [2].

If you want it DMA capable you need Renesas IPMMU support in XEN [3], 
[4] to be incorporated.


[1] - https://xenbits.xen.org/docs/unstable/misc/arm/passthrough.txt

[2] - 
https://lists.xenproject.org/archives/html/xen-users/2017-10/msg00031.html

[3] - 
https://lists.xenproject.org/archives/html/xen-devel/2017-07/msg02545.html

[4] - 
https://lists.xenproject.org/archives/html/xen-devel/2017-07/msg02679.html


-- 

*Andrii Anisov*



_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: Access I2C bus from guest/DomU on ARM board
  2018-01-16 15:52 ` Andrii Anisov
@ 2018-01-17 14:03   ` Saumya Rajesh
  2018-01-17 15:36     ` Andrii Anisov
  0 siblings, 1 reply; 9+ messages in thread
From: Saumya Rajesh @ 2018-01-17 14:03 UTC (permalink / raw)
  To: Andrii Anisov; +Cc: xen-devel, embedded-pv-devel, xen-users


[-- Attachment #1.1: Type: text/plain, Size: 1187 bytes --]

On Tue, Jan 16, 2018 at 9:22 PM, Andrii Anisov <andrii_anisov@epam.com>
wrote:

> Dear Rajesh,
>
>
> You can try to get an I2C bus controller in DomU in PIO mode following
> [1], keeping in mind [2].
>
> If you want it DMA capable you need Renesas IPMMU support in XEN [3], [4]
> to be incorporated.
>
>
> [1] - https://xenbits.xen.org/docs/unstable/misc/arm/passthrough.txt
>
> [2] - https://lists.xenproject.org/archives/html/xen-users/2017-10
> /msg00031.html
>
> [3] - https://lists.xenproject.org/archives/html/xen-devel/2017-07
> /msg02545.html
>
> [4] - https://lists.xenproject.org/archives/html/xen-devel/2017-07
> /msg02679.html
>
>
> --
>
> *Andrii Anisov*
>
>
>
Thank you Andrii for replying. I will try the device passthrough way of
using I2C bus from guest and post the updates.

Just out of curiosity, is it possible to split the Driver for the Renesas
RCar I2C unit [1] into frontend and backend to use the i2c bus from guest?
Or to do something similar to PCI passthrough? Please forgive me if I sound
illogical. I'm just curious.

Regards
Saumya

[1]
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git/tree/drivers/i2c/busses/i2c-rcar.c?h=v4.14.13

[-- Attachment #1.2: Type: text/html, Size: 2878 bytes --]

[-- Attachment #2: Type: text/plain, Size: 157 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: Access I2C bus from guest/DomU on ARM board
  2018-01-17 14:03   ` Saumya Rajesh
@ 2018-01-17 15:36     ` Andrii Anisov
  2018-01-18  7:50       ` Saumya Rajesh
  0 siblings, 1 reply; 9+ messages in thread
From: Andrii Anisov @ 2018-01-17 15:36 UTC (permalink / raw)
  To: Saumya Rajesh; +Cc: xen-devel, embedded-pv-devel

Rajesh,

On 17.01.18 16:03, Saumya Rajesh wrote:
> Just out of curiosity, is it possible to split the Driver for the 
> Renesas RCar I2C unit [1] into frontend and backend to use the i2c bus 
> from guest? Or to do something similar to PCI passthrough? Please 
> forgive me if I sound illogical. I'm just curious.
I guess you could implement PV I2C using FE/BE scheme. With enormous 
efforts and unpredictable results.
But I'm sure it is not what you really need.

-- 

*Andrii Anisov*



_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: Access I2C bus from guest/DomU on ARM board
  2018-01-17 15:36     ` Andrii Anisov
@ 2018-01-18  7:50       ` Saumya Rajesh
  2018-01-29 13:33         ` Saumya Rajesh
  2018-01-31 15:06         ` Andrii Anisov
  0 siblings, 2 replies; 9+ messages in thread
From: Saumya Rajesh @ 2018-01-18  7:50 UTC (permalink / raw)
  To: Andrii Anisov, xen-users; +Cc: xen-devel, embedded-pv-devel


[-- Attachment #1.1: Type: text/plain, Size: 1096 bytes --]

On Wed, Jan 17, 2018 at 9:06 PM, Andrii Anisov <andrii_anisov@epam.com>
wrote:

> Rajesh,
>
> On 17.01.18 16:03, Saumya Rajesh wrote:
>
>> Just out of curiosity, is it possible to split the Driver for the Renesas
>> RCar I2C unit [1] into frontend and backend to use the i2c bus from guest?
>> Or to do something similar to PCI passthrough? Please forgive me if I sound
>> illogical. I'm just curious.
>>
> I guess you could implement PV I2C using FE/BE scheme. With enormous
> efforts and unpredictable results.
> But I'm sure it is not what you really need.
>
> --
>
> *Andrii Anisov*
>
>
>
​Hi Andrii

Actually I am planning to set up Android as guest in Xen. In order to
enable sound in the Android guest, I need to passthrough the audio codec
device which communicates through the I2C bus. For BE/FE scheme, I think
sharing the internal DMA and clock would pose problems. So I'm going to go
ahead with the device passthrough way.

Any thoughts or inputs you can possibly give regarding this use case will
be very helpful and valuable.

Regards
Saumya​

[-- Attachment #1.2: Type: text/html, Size: 2566 bytes --]

[-- Attachment #2: Type: text/plain, Size: 157 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: Access I2C bus from guest/DomU on ARM board
  2018-01-18  7:50       ` Saumya Rajesh
@ 2018-01-29 13:33         ` Saumya Rajesh
  2018-01-31 15:06         ` Andrii Anisov
  1 sibling, 0 replies; 9+ messages in thread
From: Saumya Rajesh @ 2018-01-29 13:33 UTC (permalink / raw)
  To: xen-users, xen-devel, embedded-pv-devel

On Thu, Jan 18, 2018 at 1:20 PM, Saumya Rajesh <saumyarajesh93@gmail.com> wrote:
> On Wed, Jan 17, 2018 at 9:06 PM, Andrii Anisov <andrii_anisov@epam.com>
> wrote:
>>
>> Rajesh,
>>
>> On 17.01.18 16:03, Saumya Rajesh wrote:
>>>
>>> Just out of curiosity, is it possible to split the Driver for the Renesas
>>> RCar I2C unit [1] into frontend and backend to use the i2c bus from guest?
>>> Or to do something similar to PCI passthrough? Please forgive me if I sound
>>> illogical. I'm just curious.
>>
>> I guess you could implement PV I2C using FE/BE scheme. With enormous
>> efforts and unpredictable results.
>> But I'm sure it is not what you really need.
>>
>> --
>>
>> *Andrii Anisov*
>>
>>
>
> Hi Andrii
>
> Actually I am planning to set up Android as guest in Xen. In order to enable
> sound in the Android guest, I need to passthrough the audio codec device
> which communicates through the I2C bus. For BE/FE scheme, I think sharing
> the internal DMA and clock would pose problems. So I'm going to go ahead
> with the device passthrough way.
>
> Any thoughts or inputs you can possibly give regarding this use case will be
> very helpful and valuable.
>
> Regards
> Saumya
>

Hi

I am trying to passthrough I2C bus to guest domain in Xen. I am
referring [1][2][3] to implement this on Renesas R-Car H3. Following
is the list of all I2C buses available when not passed through :

root@salvator-x-xen-dom0:~# i2cdetect -l
i2c-2 i2c        e6510000.i2c                    I2C adapter
i2c-4 i2c        e66d8000.i2c                    I2C adapter
i2c-7 i2c        e60b0000.i2c                    I2C adapter
i2c-8 i2c        DesignWare HDMI                  I2C adapter
i2c-9 i2c        DesignWare HDMI                  I2C adapter

I added " xen,passthrough = "1"; " and built the Dom0 device tree to
enable I2C bus passthrough :

r8a7795.dtsi:

i2c2: i2c@e6510000 {
#address-cells = <1>;
#size-cells = <0>;
compatible = "renesas,i2c-r8a7795";
reg = <0 0xe6510000 0 0x40>;
interrupts = <GIC_SPI 286 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&cpg CPG_MOD 929>;
power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
dmas = <&dmac1 0x95>, <&dmac1 0x94>;
dma-names = "tx", "rx";
i2c-scl-internal-delay-ns = <6>;
status = "disabled";
xen,passthrough = "1";
};

After booting using the modified dtb, i2c-2 disappears, meaning it was
not taken by Dom0 :

root@salvator-x-xen-dom0:~# i2cdetect -l
i2c-4 i2c        e66d8000.i2c                    I2C adapter
i2c-7 i2c        e60b0000.i2c                    I2C adapter
i2c-8 i2c        DesignWare HDMI                  I2C adapter
i2c-9 i2c        DesignWare HDMI                  I2C adapter

I built a partial device tree guest_dtb_test.dtb using the following content :

guest_dtb_test.dts:
/dts-v1/;

/ {
    /* #*cells are here to keep DTC happy */
    #address-cells = <2>;
    #size-cells = <2>;

    aliases {
        i2c0 = &i2c0;
    };
passthrough {
compatible = "simple-bus";
ranges;
#address-cells = <2>;
#size-cells = <2>;
i2c0: i2c@10000000 {
compatible = "renesas,i2c-r8a7795";
reg = <0 0x10000000 0 0x40>;
interrupts = <0 286 4>;
#address-cells = <1>;
#size-cells = <0>;
status = "okay";
};
};
};

I also added the following lines to DomU configuration file :

device_tree = "/root/guest_test_dtb.dtb"
dtdev = [ "/soc/i2c@e6510000" ]
irqs = [ 318 ]
iomem = [ "0xe6510,1" ]

But when I start DomU, the booting fails. Log of starting DomU :

root@salvator-x-xen-dom0:~# xl create -c Domu.cfg
Parsing config from Domu.cfg
[ 2160.083551] rcar_gen3_thermal e61a8000.thermal: Can't register thermal zone
(XEN) avc:  denied  { use } for domid=0 irq=318
scontext=system_u:system_r:domU_t tcontext=system_u:object_r:irq_t
tclass=resource
libxl: error: libxl_create.c:1284:domcreate_launch_dm: failed give
dom2 access to irq 318: Permission denied
libxl: error: libxl.c:1575:libxl__destroy_domid: non-existant domain 2
libxl: error: libxl.c:1534:domain_destroy_callback: unable to destroy
guest with domid 2

libxl: error: libxl.c:1463:domain_destroy_cb: destruction of domain 2 failed

Seeing the log, I guess the irq could not be given to DomU. It is
actually 286 + 32, as it was mentioned in [1].

Is there a workaround to this issue? Any solution or suggestion
related to this will be much appreciated.

Regards
Saumya

[1] https://xenbits.xen.org/docs/unstable/misc/arm/passthrough.txt
[2] https://events.static.linuxfound.org/sites/events/files/slides/talk_5.pdf
[3] https://lists.xenproject.org/archives/html/xen-users/2017-10/msg00031.html

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: Access I2C bus from guest/DomU on ARM board
  2018-01-18  7:50       ` Saumya Rajesh
  2018-01-29 13:33         ` Saumya Rajesh
@ 2018-01-31 15:06         ` Andrii Anisov
  2018-02-01 13:48           ` Saumya Rajesh
  1 sibling, 1 reply; 9+ messages in thread
From: Andrii Anisov @ 2018-01-31 15:06 UTC (permalink / raw)
  To: Saumya Rajesh; +Cc: xen-devel, embedded-pv-devel

Hello Saumya,


On 18.01.18 09:50, Saumya Rajesh wrote:
> Actually I am planning to set up Android as guest in Xen.
I see.

> In order to enable sound in the Android guest, I need to passthrough 
> the audio codec device which communicates through the I2C bus. For 
> BE/FE scheme, I think sharing the internal DMA and clock would pose 
> problems. So I'm going to go ahead with the device passthrough way.
Passing through I2C bus to guest domain would not be enough to get sound 
in Android. You would face more dependencies, and they may appear not 
solvable.

> Any thoughts or inputs you can possibly give regarding this use case 
> will be very helpful and valuable.
We are using PV Audio solution for such a task:

https://lists.xenproject.org/archives/html/xen-devel/2017-03/msg02428.html
https://lkml.org/lkml/2017/8/7/115

-- 

*Andrii Anisov*



_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: Access I2C bus from guest/DomU on ARM board
  2018-01-31 15:06         ` Andrii Anisov
@ 2018-02-01 13:48           ` Saumya Rajesh
  0 siblings, 0 replies; 9+ messages in thread
From: Saumya Rajesh @ 2018-02-01 13:48 UTC (permalink / raw)
  To: Andrii Anisov, xen-devel, embedded-pv-devel, xen-users

On Wed, Jan 31, 2018 at 8:36 PM, Andrii Anisov <andrii_anisov@epam.com> wrote:
> Hello Saumya,
>
>
> On 18.01.18 09:50, Saumya Rajesh wrote:
>>
>> Actually I am planning to set up Android as guest in Xen.
>
> I see.
>
>> In order to enable sound in the Android guest, I need to passthrough the
>> audio codec device which communicates through the I2C bus. For BE/FE scheme,
>> I think sharing the internal DMA and clock would pose problems. So I'm going
>> to go ahead with the device passthrough way.
>
> Passing through I2C bus to guest domain would not be enough to get sound in
> Android. You would face more dependencies, and they may appear not solvable.
>
>> Any thoughts or inputs you can possibly give regarding this use case will
>> be very helpful and valuable.
>
> We are using PV Audio solution for such a task:
>
> https://lists.xenproject.org/archives/html/xen-devel/2017-03/msg02428.html
> https://lkml.org/lkml/2017/8/7/115
>
> --
>
> *Andrii Anisov*
>
>

Hi Andrii

I guess you are right. I am already facing issues in doing I2C bus
passthrough. If you find time, please look into [1][2].

I was able to successfully build and execute the PV Audio solution on
R-Car H3, with xen-front[3] as frontend and snd_be[4] as backend. The
only issue I encountered was that Dom0 could not use the sound card as
long as the backend application ran. It is the only working solution
that I have found till now.

I think I am back to square one but I can't help but ask if you are
familiar with any work which is going on in Xen which makes it
possible for the guest domain(Linux based) to interact with all kinds
of I2C devices such as audio SoCs or sensors?

Regards
Saumya

[1] https://lists.xenproject.org/archives/html/xen-devel/2018-01/msg02711.html
[2] https://lists.xenproject.org/archives/html/xen-devel/2018-01/msg02618.html
[3] https://lists.xen.org/archives/html/xen-devel/2017-08/msg00626.html
[4] https://github.com/xen-troops/snd_be

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

end of thread, other threads:[~2018-02-01 13:48 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-16 13:39 Access I2C bus from guest/DomU on ARM board Saumya Rajesh
2018-01-16 14:46 ` Lars Kurth
2018-01-16 15:52 ` Andrii Anisov
2018-01-17 14:03   ` Saumya Rajesh
2018-01-17 15:36     ` Andrii Anisov
2018-01-18  7:50       ` Saumya Rajesh
2018-01-29 13:33         ` Saumya Rajesh
2018-01-31 15:06         ` Andrii Anisov
2018-02-01 13:48           ` Saumya Rajesh

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.