Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 6 Next »

Passthrough allows you to give control of physical devices to guests domus. This page has a few examples for device passthroughs.

PSUART assignment

Turn xen.dtb into xen.dts:

dtc -I dtb -O dts xen.dtb > xen.dts

The, edit xen.dts by adding xen,passthrough; under the node of the device to assign, in this case serial@ff000000:

serial@ff010000 {
			compatible = "cdns,uart-r1p12", "xlnx,xuartps";
			status = "okay";
			interrupt-parent = <0xfde8>;
			interrupts = <0x0 0x16 0x4>;
			reg = <0x0 0xff010000 0x1000>;
			device_type = "serial";
			clock-names = "uart_clk", "pclk";
			power-domains = <0x26 0x22>;
			clocks = <0x1e 0x1f>;
			cts-override;
			port-number = <0x1>;
			xen,passthrough; /* add this line */
		};

Convert xen.dts back into xen.dtb:

dtc -I dts -O dtb xen.dts > xen.dtb

To enable the PSUART assignment to a domU. Below is one example for the dom create config file. 

irqs = [ 54 ]
iomem = [ "0xff010,1" ]
device_tree = "/root/passthrough-serial.dtb"
dtdev = [ "/amba/serial@ff010000" ]

In above config file, irqs and iomem entries are added. Here is detailed explanation for these entries:

IRQS calculation

To calculate irqs corresponding to the guest domain, it needs to find the following line in UART settings described in xen.dts file:

serial@ff010000 {
			compatible = "cdns,uart-r1p12", "xlnx,xuartps";
			status = "okay";
			interrupt-parent = <0xfde8>;
			interrupts = <0x0 0x16 0x4>;

take the interrupt which is device specific, in this case interrupt number is 0x16, add 32 which is the base address of interrupt handler.

0x16 = 22
irqs = 22 + 32 = 54

Setup IOMEM field

iomem = [ "0xff010,1" ]
1 page starting at "0xFF010000" base address of UART PS.

Creation of passthrough-serial.dts:

/dts-v1/;

/ {
	#address-cells = <0x2>;
	#size-cells = <0x2>;

	passthrough {
		compatible = "simple-bus";
		ranges;
		#address-cells = <0x2>;
		#size-cells = <0x2>;

		pss_ref_clk {
			compatible = "fixed-clock";
			#clock-cells = <0x0>;
			clock-frequency = <0x1fc9350>;
			phandle = <0x6>;
		};

		video_clk {
			compatible = "fixed-clock";
			#clock-cells = <0x0>;
			clock-frequency = <0x19bfcc0>;
			phandle = <0x7>;
		};

		pss_alt_ref_clk {
			compatible = "fixed-clock";
			#clock-cells = <0x0>;
			clock-frequency = <0x0>;
			phandle = <0x8>;
		};

		gt_crx_ref_clk {
			compatible = "fixed-clock";
			#clock-cells = <0x0>;
			clock-frequency = <0x66ff300>;
			phandle = <0xa>;
		};

		aux_ref_clk {
			compatible = "fixed-clock";
			#clock-cells = <0x0>;
			clock-frequency = <0x19bfcc0>;
			phandle = <0x9>;
		};

		firmware {
			zynqmp-firmware {
				compatible = "xlnx,zynqmp-firmware";
				method = "smc";
				#power-domain-cells = <0x1>;
				phandle = <0x26>;

				clock-controller {
					u-boot,dm-pre-reloc;
					#clock-cells = <0x1>;
					compatible = "xlnx,zynqmp-clk";
					clocks = <0x6 0x7 0x8 0x9 0xa>;
					clock-names = "pss_ref_clk", "video_clk", "pss_alt_ref_clk", "aux_ref_clk", "gt_crx_ref_clk";
					phandle = <0x3>;
				};
			};
		};

		serial@ff010000 {
			compatible = "cdns,uart-r1p12", "xlnx,xuartps";
			status = "okay";
			interrupt-parent = <0xfde8>;
			interrupts = <0x0 0x16 0x4>;
			reg = <0x0 0xff010000 0x0 0x1000>;
			clock-names = "uart_clk", "pclk";
			clocks = <0x3 0x39 0x3 0x1f>;
			device_type = "serial";
			port-number = <0x1>;
			xen,path = "/amba/serial@ff010000";
			xen,reg = <0x0 0xff010000 0x1000 0x0 0xff010000>;
		};
	};
};

Copy the above device tree code snippet and save it as passthrough-serial.dts and convert the above dtc into dtb using dtc compiler:

dtc -I dts -O dtb -o passthrough-serial.dtb passthrough-serial.dts

Finally, create a new guest using ‘xl create -c configfile'.

If your domU is Linux, make sure to add console=ttyPS1,115200 to its kernel command line. In case of dom0less DomUs, you have to edit the boot.source script to add the command line option, then recreate boot.scr with mkimage.

Check Starting Linux guests with Pass-through networking for another passthrough example.

  • No labels