[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-users] [Xen-devel] Access I2C bus from guest/DomU on ARM board



On Thu, Jan 18, 2018 at 1:20 PM, Saumya Rajesh <saumyarajesh93@xxxxxxxxx> wrote:
> On Wed, Jan 17, 2018 at 9:06 PM, Andrii Anisov <andrii_anisov@xxxxxxxx>
> 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-users mailing list
Xen-users@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-users

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.