Skip to contentSkip to conversation

xen: clk: introudce pvclk for device passthrough

RFC/WIP Peng Fan 4 participants 15 messages Jan 16, 2016 – Jan 19, 2016

Subsystems (2)
lore
Share & tools
lore

Peng Fan

author
#0 lore raw

This patch was just a initial patch, not sure whether this way is ok from you side for handlding clk when doing platform device passhthrough. Any comments are appreciated, and your comments may give me a better direction.

Patch was basically tested with passthrough uart2 to DomU on freescale i.MX7D(Cortex-A7 Dual) platform with two linux os running based on xen hypervisor.

I have not written the userspace libxl pvclk code, so I use the libxl pvusb code for test, only need to change the compatible string in this patch from "vclk" to "vusb", and "clk-ring-ref" to "urb-ring-ref". If this patch is a acceptable way, I'll begin coding the userspace libxl pvclk.

I follow this doc [1] to do platform device passthrough, but I also met the issue how to handle clk in the DomU guest. I do not want to remove the clk api such clk_prepare_enable/disable and etc in the uart driver, since it work well without xen. But if want the uart driver to work well in DomU, I need to take care the clk usage. Without this patch, clk_prepare_enable/disable will fail because no clk tree in DomU. So I wrote this patch,

Since xen pv use asynchronous notification, clk_enable/disable can not be implemented in the map, so I use clk_prepare_enable/disable in backend to map clk_prepare/unprepare in frontend.

Partial dts for DomU linux:
"

        aliases {
		serial0 = &uart2;
		clk0 = &clks;
	};

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

		clks: clks {
			compatible = "xen,xen-clk";
			#clock-cells = <1>;
			clock-output-names = "uart2_root_clk";
		};

		uart2: serial@10000000 {
			compatible = "fsl,imx7d-uart", "fsl,imx6q-uart", "fsl,imx21-uart";
			reg = <0x10000000 0x10000>;
			interrupts = <0 27 4>;
			interrupt-parent = <65000>;
			clocks = <&clks 0>, <&clks 0>;
			clock-names = "ipg", "per";
		};
	};

"

Xen front clk driver will register itself by probing "xen,xen-clk", register clk tree by parsing "clock-output-names" and register as ROOT clk. See the uart2 node, ipg and per clks are also registered in Dom0, when DomU want to prepare or set rate for the ipg clk, DomU will use pvclk interface to pass the name "ipg" and the ID(PREPARE, SET_RATE and etc)to Dom0, Dom0 will use __clk_lookup to find out the "struct clk *" structure and prepare_enable or set_rate according to the ID from DomU. The ID is defined in clkif.h in this patch.

The mapping between frontend and backend is as following:

Frontend Backend

clk_prepare             clk_prepare_enable
clk_unprepare           clk_unprepare_disable
clk_set_rate            clk_set_rate
clk_get_rate            clk_get_rate

Frontend work flow example:
1. clk_prepare("ipg")

    |->ID: PREPARE, name: "ipg" packed into a structure
              |->notify backend

2. wait_completion
Dom0 finished clk_prepare_enable and send event channel interrupt to DomU, In DomU frontend interrupt handler, call complete to wakeup.

[1] https://events.linuxfoundation.org/sites/events/files/slides/talk_5.pdf

Cc Konrad Rzeszutek Wilk <[email protected]>
Cc Boris Ostrovsky <[email protected]>
Cc David Vrabel <[email protected]>
Cc Julien Grall <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Ian Campbell <[email protected]>
Cc Michael Turquette <[email protected]>
Cc Stephen Boyd <[email protected]>
---
 drivers/clk/Makefile             |   2 +
 drivers/clk/xen/Makefile         |   1 +
 drivers/clk/xen/clk-xen.c        | 197 ++++++++++++++++++
 drivers/clk/xen/xen-clkback.c    | 357 ++++++++++++++++++++++++++++++++
 drivers/clk/xen/xen-clkfront.c   | 432 +++++++++++++++++++++++++++++++++++++++
 include/xen/interface/io/clkif.h |  41 ++++
 6 files changed, 1030 insertions(+)
 create mode 100644 drivers/clk/xen/Makefile
 create mode 100644 drivers/clk/xen/clk-xen.c
 create mode 100644 drivers/clk/xen/xen-clkback.c
 create mode 100644 drivers/clk/xen/xen-clkfront.c
 create mode 100644 include/xen/interface/io/clkif.h
drivers/clk/Makefile +2 -0
index 820714c..7668ecc 100644
@@ -15,6 +15,8 @@ ifeq ($(CONFIG_OF), y)
 obj-$(CONFIG_COMMON_CLK)	+= clk-conf.o
 endif
 
+obj-$(CONFIG_XEN)		+= xen/
+
 # hardware specific clock types
 # please keep this section sorted lexicographically by file/directory path name
 obj-$(CONFIG_MACH_ASM9260)		+= clk-asm9260.o
drivers/clk/xen/Makefile new file +1 -0
new file mode 100644
index 0000000..60abe25
@@ -0,0 +1 @@
+obj-y		+= clk-xen.o xen-clkfront.o xen-clkback.o
drivers/clk/xen/clk-xen.c new file +197 -0

197 lines not on this page · raw message

drivers/clk/xen/xen-clkback.c new file +357 -0

357 lines not on this page · raw message

drivers/clk/xen/xen-clkfront.c new file +432 -0

432 lines not on this page · raw message

include/xen/interface/io/clkif.h new file +41 -0

41 lines not on this page · raw message

Signature · 1 line
2.6.2
#1 lore raw
Quoted 4 lines · Peng Fan

This patch was just a initial patch, not sure whether this way is ok from you side for handlding clk when doing platform device passhthrough. Any comments are appreciated, and your comments may give me a better direction.

Hey Peng,

Just speaking from the perspective of a Xen dev who's not an ARM dev:
a few more words on the relationship between pvclk and device-passthrough would be helpful to set the context. It sounds like:

* On ARM, passing through a device requires a clocksource (at least for many devices)

* dom0 has the hardware clocksource, but at the moment domUs don't have a suitable clocksource

* This patch implements pvclk front/backend suitable for such devices

Is that right? In which case something like the following would be helpful:

"This patch introduces pvclk, a paravirtualized clock source suitable for devices to use when passing through to domUs on ARM systems."

(Obviously change it as necessary to make it accurate.)

Thanks,
-George

author
#2 lore raw

Hello George,

Quoted 16 lines · George Dunlap
Quoted 4 lines · Peng Fan

This patch was just a initial patch, not sure whether this way is ok from you side for handlding clk when doing platform device passhthrough. Any comments are appreciated, and your comments may give me a better direction.

Hey Peng,

Just speaking from the perspective of a Xen dev who's not an ARM dev:
a few more words on the relationship between pvclk and device-passthrough would be helpful to set the context. It sounds like:

* On ARM, passing through a device requires a clocksource (at least for many devices)

Quoted 6 lines

* dom0 has the hardware clocksource, but at the moment domUs don't have a suitable clocksource

* This patch implements pvclk front/backend suitable for such devices

Is that right? In which case something like the following would be helpful:

Yeah. right. You have a better explaination than me :)

Quoted 5 lines

"This patch introduces pvclk, a paravirtualized clock source suitable for devices to use when passing through to domUs on ARM systems."

(Obviously change it as necessary to make it accurate.)

I'll add your words into the commit log.

Thanks,
Peng.

Quoted 3 lines

Thanks,
-George

author
#3 lore raw
In reply to George Dunlap

Hello George,

Quoted 16 lines · George Dunlap
Quoted 4 lines · Peng Fan

This patch was just a initial patch, not sure whether this way is ok from you side for handlding clk when doing platform device passhthrough. Any comments are appreciated, and your comments may give me a better direction.

Hey Peng,

Just speaking from the perspective of a Xen dev who's not an ARM dev:
a few more words on the relationship between pvclk and device-passthrough would be helpful to set the context. It sounds like:

* On ARM, passing through a device requires a clocksource (at least for many devices)

Quoted 6 lines

* dom0 has the hardware clocksource, but at the moment domUs don't have a suitable clocksource

* This patch implements pvclk front/backend suitable for such devices

Is that right? In which case something like the following would be helpful:

Yeah. right. You have a better explaination than me :)

Quoted 5 lines

"This patch introduces pvclk, a paravirtualized clock source suitable for devices to use when passing through to domUs on ARM systems."

(Obviously change it as necessary to make it accurate.)

I'll add your words into the commit log.

Thanks,
Peng.

Quoted 3 lines

Thanks,
-George

#4 lore raw
In reply to Peng Fan
Quoted 4 lines · Peng Fan

This patch was just a initial patch, not sure whether this way is ok from you side for handlding clk when doing platform device passhthrough. Any comments are appreciated, and your comments may give me a better direction.

Hey Peng,

Just speaking from the perspective of a Xen dev who's not an ARM dev:
a few more words on the relationship between pvclk and device-passthrough would be helpful to set the context. It sounds like:

* On ARM, passing through a device requires a clocksource (at least for many devices)

* dom0 has the hardware clocksource, but at the moment domUs don't have a suitable clocksource

* This patch implements pvclk front/backend suitable for such devices

Is that right? In which case something like the following would be helpful:

"This patch introduces pvclk, a paravirtualized clock source suitable for devices to use when passing through to domUs on ARM systems."

(Obviously change it as necessary to make it accurate.)

Thanks,
-George

#5 lore raw
In reply to Peng Fan
Quoted 4 lines · Peng Fan

This patch was just a initial patch, not sure whether this way is ok from you side for handlding clk when doing platform device passhthrough. Any comments are appreciated, and your comments may give me a better direction.

There's no documentation on the interface, which makes it difficult to review. At a first look it looks very specific to the particular Linux implementation of a clk subsystem.

include/xen/interface/io/clkif.h line 8

Quoted 11 lines
include/xen/interface/io/clkif.h new file +8 -0
@@ -0,0 +1,41 @@
+/*
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */

ABIs should be under a more permissive license so they can be used by other (non-GPLv2) operating systems.

Quoted 8 lines
include/xen/interface/io/clkif.h new file +8 -0
+
+#ifndef __XEN_PUBLIC_IO_CLKIF_H__
+#define __XEN_PUBLIC_IO_CLKIF_H__
+
+#include <xen/interface/io/ring.h>
+#include <xen/interface/grant_table.h>
+
+/**/

include/xen/interface/io/clkif.h line 26

Quoted 10 lines
include/xen/interface/io/clkif.h new file +10 -0
+enum {
+	XENCLK_PREPARE,		/* clk_prepare_enable */
+	XENCLK_UNPREPARE,	/* clk_unprepare_disable */
+	XENCLK_GET_RATE,	/* clk_get_rate */
+	XENCLK_SET_RATE,	/* clk_set_rate */
+	XENCLK_END,
+};
+
+struct xen_clkif_request {
+	int id;

You should use fixed width types so the ABI is the same on 32-bit and 64-bit guests.

include/xen/interface/io/clkif.h line 28

Quoted 2 lines
include/xen/interface/io/clkif.h new file +2 -0
+	unsigned long rate;
+	char clk_name[32];

Where does the frontend get these names from? 31 character names seems rather limiting.

include/xen/interface/io/clkif.h line 36

Quoted 8 lines
include/xen/interface/io/clkif.h new file +8 -0
+};
+
+struct xen_clkif_response {
+	int id;
+	int success;
+	unsigned long rate;
+	char clk_name[32];
+};

I don't think you need to the name in the response. The id will tie the response to the request.

Quoted 6 lines
include/xen/interface/io/clkif.h new file +5 -0
+
+DEFINE_RING_TYPES(xen_clkif, struct xen_clkif_request, struct xen_clkif_response);
+#define XEN_CLK_RING_SIZE __CONST_RING_SIZE(xen_clkif, PAGE_SIZE)
+
+#endif
#6 lore raw
Quoted 8 lines · David Vrabel
Quoted 4 lines · Peng Fan

This patch was just a initial patch, not sure whether this way is ok from you side for handlding clk when doing platform device passhthrough. Any comments are appreciated, and your comments may give me a better direction.

=20
There's no documentation on the interface, which makes it difficult to review.=C2=A0=C2=A0At a first look it looks very specific to the particul=

ar Linux

Quoted 16 lines

implementation of a clk subsystem.
=20

include/xen/interface/io/clkif.h line 8

Quoted 11 lines
include/xen/interface/io/clkif.h new file +8 -0
@@ -0,0 +1,41 @@
+/*
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */

=20
ABIs should be under a more permissive license so they can be used by other (non-GPLv2) operating systems.

... along the same lines proposals for new ABIs should be made in the form of patches to xen.git:xen/include/public/io/ before being submitted as an implementation for one particular os.

Quoted 4 lines

include/xen/interface/io/clkif.h line 10

Quoted 2 lines
include/xen/interface/io/clkif.h new file +2 -0
+	unsigned long rate;
+	char clk_name[32];

=20
Where does the frontend get these names from?=C2=A0=C2=A031 character nam=

es seems

Quoted 1 line

rather limiting.

Indeed.

At a guess I would assume they come from the device-tree given to the guest and tie into the host device tree.

I think a better model might be for each clk to have it's own subdirectory under the overall clock bus node, e.g. something like:

/local/domain/<...>/clk/0/nr-clks =3D 4
/local/domain/<...>/clk/0/clk-0/ ...
/local/domain/<...>/clk/0/clk-1/ ...
/lo
cal/domain/<...>/clk/0/clk-2/ ...
/local/domain/<...>/clk/0/clk-3/ ...

and for each subdirectory to contain the a node containing the correspondin= g firmware table identifier (so path in the DT case), which the toolstack k= nows, so it can setup the f/e and b/e to correspond as necessary, and the f= /e device needn't necessarily use the same name as the backend/host).

The request would then include the index and not the name (and as David obs= erves the response only needs the id).

As well as properly documenting the meaning of the operations=C2=A0 the clkif.h should also define the xenstore nodes and contain the binary la= youts of the req/rsp structs (see netif.h for examples of both, blkif.h als=
o includes examples of the former).

I'd also like to see a description of the DT bindings, which I assume must = be needed such that the devices clocks property has something to refer to. = For example maybe it doesn't make sense for xenstore to contain the path, b= ut for the pvclk node in xenstore to contain the index.

Quoted 8 lines
Quoted 7 lines
include/xen/interface/io/clkif.h new file +2 -0
+
+DEFINE_RING_TYPES(xen_clkif, struct xen_clkif_request, struct

xen_clkif_response);

include/xen/interface/io/clkif.h new file +3 -0
+#define XEN_CLK_RING_SIZE __CONST_RING_SIZE(xen_clkif, PAGE_SIZE)
+
+#endif

=20

=20

author
#7 lore raw

Hello Ian,

Quoted 26 lines · Ian Campbell
Quoted 10 lines · David Vrabel
Quoted 4 lines · Peng Fan

This patch was just a initial patch, not sure whether this way is ok from you side for handlding clk when doing platform device passhthrough. Any comments are appreciated, and your comments may give me a better direction.

There's no documentation on the interface, which makes it difficult to review.  At a first look it looks very specific to the particular Linux implementation of a clk subsystem.

Quoted 14 lines

include/xen/interface/io/clkif.h line 8

Quoted 11 lines
include/xen/interface/io/clkif.h new file +8 -0
@@ -0,0 +1,41 @@
+/*
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */

ABIs should be under a more permissive license so they can be used by other (non-GPLv2) operating systems.

Quoted 3 lines

... along the same lines proposals for new ABIs should be made in the form of patches to xen.git:xen/include/public/io/ before being submitted as an implementation for one particular os.

I had no idea about this before. Do you mean that before I implement pvclk for linux, I need to first post the clkif part to xen devel?

If it is, I'll split the interface part and send this part to [email protected] for review.

Quoted 8 lines
Quoted 7 lines

include/xen/interface/io/clkif.h line 10

Quoted 4 lines
include/xen/interface/io/clkif.h new file +2 -0
+	unsigned long rate;
+	char clk_name[32];

Where does the frontend get these names from?  31 character names seems rather limiting.

Quoted 4 lines

Indeed.

At a guess I would assume they come from the device-tree given to the guest and tie into the host device tree.

Yeah. the clk_name is got from DomU dts, and in Dom0 there is also a same name.

Quoted 11 lines

I think a better model might be for each clk to have it's own subdirectory under the overall clock bus node, e.g. something like:

/local/domain/<...>/clk/0/nr-clks = 4
/local/domain/<...>/clk/0/clk-0/ ...
/local/domain/<...>/clk/0/clk-1/ ...
/lo
cal/domain/<...>/clk/0/clk-2/ ...
/local/domain/<...>/clk/0/clk-3/ ...

Quoted 3 lines

and for each subdirectory to contain the a node containing the corresponding firmware table identifier (so path in the DT case), which the toolstack knows, so it can setup the f/e and b/e to correspond as necessary, and the f/e device needn't necessarily use the same name as the backend/host).

The request would then include the index and not the name (and as David observes the response only needs the id).

For now, I have not began the userspace libxl part for pvclk, I use the libxl pvusb code for test (:
The id acctually means what operation is needed, such as CLK_PREPARE, CLK_UNPREPARE, CLK_SET_RATE, CLK_GET_RATE. I'll add more text to document this in V2.

Quoted 3 lines

As well as properly documenting the meaning of the operations
the clkif.h should also define the xenstore nodes and contain the binary layouts of the req/rsp structs (see netif.h for examples of both, blkif.h also includes examples of the former).

ok. I'll take netif/blkif for reference.

Quoted 2 lines

I'd also like to see a description of the DT bindings, which I assume must be needed such that the devices clocks property has something to refer to. For example maybe it doesn't make sense for xenstore to contain the path, but for the pvclk node in xenstore to contain the index.

The DT bindings for xen pvclk, I use this:
"

                clks: clks {
			compatible = "xen,xen-clk";
			#clock-cells = <1>;
			clock-output-names = "uart2_root_clk";
		};
"
the clock-output-names will be parsed and be registered as clk root. The device will use index to refer to the clk, as the following:
"
                clocks = <&clks 0>, <&clks 0>;
	        clock-names = "ipg", "per";

"
0 means the first one in clock-output-names.

To the xenstore part, I am not sure whether need to expose the clock relate info to xenstore. I just want to store the clock names in xenstore to let user know what clocks are now handled by DomU.

How about the following?

doamin1:
/local/domain/1/device/vclk/nr-clks
/local/domain/1/device/vclk/clk-0/name
/local/domain/1/device/vclk/clk-1/name

domain2:
/local/domain/2/device/vclk/nr-clks
/local/domain/2/device/vclk/clk-0/name
/local/domain/2/device/vclk/clk-1/name

domain0:
/local/domain/0/backend/vclk/1/0/nr-clks
/local/domain/0/backend/vclk/1/0/clk-0/name
/local/domain/0/backend/vclk/1/0/clk-1/name
/local/domain/0/backend/vclk/1/1/nr-clks
/local/domain/0/backend/vclk/1/1/clk-0/name
/local/domain/0/backend/vclk/1/1/clk-1/name

Or do not store the name and nr-clks in domain0?

Thanks,
Peng.

Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
include/xen/interface/io/clkif.h new file +2 -0
+
+DEFINE_RING_TYPES(xen_clkif, struct xen_clkif_request, struct

xen_clkif_response);

include/xen/interface/io/clkif.h new file +3 -0
+#define XEN_CLK_RING_SIZE __CONST_RING_SIZE(xen_clkif, PAGE_SIZE)
+
+#endif
#8 lore raw
Quoted 13 lines · Peng Fan

Hello Ian,
=20

Quoted 10 lines · Ian Campbell
Quoted 9 lines · David Vrabel
Quoted 4 lines · Peng Fan

This patch was just a initial patch, not sure whether this way is ok from you side for handlding clk when doing platform device passhthrough. Any comments are appreciated, and your comments may give me a better direction.

=20
There's no documentation on the interface, which makes it difficult to
review.=C2=A0=C2=A0At a first look it looks very specific to the part=

icular

Quoted 25 lines
Quoted 19 lines
Quoted 19 lines

Linux
implementation of a clk subsystem.
=20

Quoted 5 lines
include/xen/interface/io/clkif.h new file +2 -0
@@ -0,0 +1,41 @@
+/*
+ * The code contained herein is licensed under the GNU General
Quoted 8 lines

Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */

=20
ABIs should be under a more permissive license so they can be used by other (non-GPLv2) operating systems.

Quoted 6 lines

=20
... along the same lines proposals for new ABIs should be made in the form
of patches to xen.git:xen/include/public/io/ before being submitted as an
implementation for one particular os.

Quoted 6 lines

=20
I had no idea about this before. Do you mean that before I implement pvclk for linux, I need to first post the clkif part to xen devel? =20
If it is, I'll split the interface part and send this part to [email protected] for review.

Yes, please.

xen.git contains the canonical definition of all Xen PV protocols, copies are then taking into OSes for implementation purposes.

Quoted 7 lines

=20

Quoted 6 lines

=20
=20

Quoted 4 lines

include/xen/interface/io/clkif.h

Quoted 2 lines
include/xen/interface/io/clkif.h new file +2 -0
+	unsigned long rate;
+	char clk_name[32];

=20
Where does the frontend get these names from?=C2=A0=C2=A031 character=

names

Quoted 32 lines
Quoted 8 lines
Quoted 2 lines

seems
rather limiting.

=20
Indeed.
=20
At a guess I would assume they come from the device-tree given to the guest
and tie into the host device tree.

=20
Yeah. the clk_name is got from DomU dts, and in Dom0 there is also a same name.
=20

Quoted 12 lines

=20
I think a better model might be for each clk to have it's own subdirectory
under the overall clock bus node, e.g. something like:
=20
/local/domain/<...>/clk/0/nr-clks =3D 4 /local/domain/<...>/clk/0/clk-0/ ... /local/domain/<...>/clk/0/clk-1/ ...
/lo
cal/domain/<...>/clk/0/clk-2/ ... /local/domain/<...>/clk/0/clk-3/ ...
=20

Quoted 8 lines

and for each subdirectory to contain the a node containing the corresponding firmware table identifier (so path in the DT case), which the toolstack knows, so it can setup the f/e and b/e to correspond as necessary, and the f/e device needn't necessarily use the same name as the backend/host).
=20
The request would then include the index and not the name (and as David observes the response only needs the id).

Quoted 3 lines

=20
For now, I have not began the userspace libxl part for pvclk, I use the libxl pvusb code for test (:

Sure, but eventually this will need implementing in the toolstack and the protocol design should be what is most suitable for the usecase, not what happens to be most convenient for testing via some quick hack.

Quoted 3 lines

The id acctually means what operation is needed, such as CLK_PREPARE, CLK_UNPREPARE, CLK_SET_RATE, CLK_GET_RATE. I'll add more text to document this in V2.

Ah, then for consistency with other PV protocols I would suggest renaming your "id" as "cmd" and adding an "id" field which is simply echoed in the response to allow the frontend to match responses to requests.

Note however that the important thing in my paragraphs above was the decoupling of the naming from the f/e and b/e and avoiding the use of the DT specific path in the ring requests.

The PV protocol should ideally be independent of DT (lets assume we will want to use it for e.g. ACPI too), although there would probably in this case need to be a binding from the DT world to the pvclk world to allow the guest DT to remain consistent (i.e. so devices have something they can point at which can be resolved into a pvclk).

Quoted 10 lines
Quoted 6 lines

=20
I'd also like to see a description of the DT bindings, which I assume must be needed such that the devices clocks property has something to refer to. For example maybe it doesn't make sense for xenstore to contain the path, but for the pvclk node in xenstore to contain the index.

=20
The DT bindings for xen pvclk, I use this:
" =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=

=C2=A0=C2=A0=C2=A0=C2=A0clks: clks {

Quoted 9 lines
			compatible =3D "xen,xen-clk";
			#clock-cells =3D <1>;
			clock-output-names =3D "uart2_root_clk";
		};

"
the clock-output-names will be parsed and be registered as clk root. The device will use index to refer to the clk, as the following:
" =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=

=C2=A0=C2=A0=C2=A0=C2=A0clocks =3D <&clks 0>, <&clks 0>;

Quoted 1 line
	=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0clock-names =3D "ipg", "=

per";

Quoted 2 lines

"
0 means the first one in clock-output-names.

This binding should be defined in Documentation/devicetree/Bindings in the usual way.

Quoted 4 lines

=20
To the xenstore part, I am not sure whether need to expose the clock relate info to xenstore. I just want to store the clock names in xenstore to let

Quoted 8 lines

user know what clocks are now handled by DomU.
=20
How about the following?
=20
doamin1:
/local/domain/1/device/vclk/nr-clks
/local/domain/1/device/vclk/clk-0/name
/local/domain/1/device/vclk/clk-1/name

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0^/0

Quoted 5 lines

=20
domain2:
/local/domain/2/device/vclk/nr-clks
/local/domain/2/device/vclk/clk-0/name
/local/domain/2/device/vclk/clk-1/name

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0^/0

Quoted 5 lines

=20
domain0:
/local/domain/0/backend/vclk/1/0/nr-clks
/local/domain/0/backend/vclk/1/0/clk-0/name
/local/domain/0/backend/vclk/1/0/clk-1/name

Correct.

Quoted 3 lines

/local/domain/0/backend/vclk/1/1/nr-clks
/local/domain/0/backend/vclk/1/1/clk-0/name
/local/domain/0/backend/vclk/1/1/clk-1/name

Should be:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 /2/0

In /local/domain/*/device/vclk/<N> the <N> is the devid or bus number (better to think of it as the latter in this case).

In /local/domain/<X>/backend/vclk/<Y>/<Z>/ you have:
X -- the backend domid (may not be 0 in all cases, needs to be planned for but not necessarily implemented)
Y -- the frontend domain
Z -- the devid/bus within frontend domain

Quoted 1 line

Or do not store the name and nr-clks in domain0?

The f/e directory should contain the identifier which the frontend needs to =C2=A0do the lookup from the firmware tables into pvclk space -- i.e. the n= ame
given in the f/e device tree node (maybe call it dt-name?).

The b/e directory should contain the name of the clock from the backend (i.e. host) pov i.e. the thing which needs to be looked up in the host firmware tables.

The two names are not necessarily the same, just as a thought experiment consider a DT using domU on an ACPI host or vice versa.

Ian.

#9 lore raw
In reply to Peng Fan
Quoted 39 lines · Peng Fan

Hello Ian,

Quoted 30 lines · Ian Campbell
Quoted 12 lines · David Vrabel
Quoted 4 lines · Peng Fan

This patch was just a initial patch, not sure whether this way is ok from you side for handlding clk when doing platform device passhthrough. Any comments are appreciated, and your comments may give me a better direction.

There's no documentation on the interface, which makes it difficult to
review.  At a first look it looks very specific to the particular Linux
implementation of a clk subsystem.

Quoted 16 lines
Quoted 5 lines
include/xen/interface/io/clkif.h new file +2 -0
@@ -0,0 +1,41 @@
+/*
+ * The code contained herein is licensed under the GNU General
Quoted 8 lines

Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */

ABIs should be under a more permissive license so they can be used by other (non-GPLv2) operating systems.

Quoted 5 lines

... along the same lines proposals for new ABIs should be made in the form
of patches to xen.git:xen/include/public/io/ before being submitted as an
implementation for one particular os.

Quoted 5 lines

I had no idea about this before. Do you mean that before I implement pvclk for linux, I need to first post the clkif part to xen devel?

If it is, I'll split the interface part and send this part to [email protected] for review.

Yes, please.

xen.git contains the canonical definition of all Xen PV protocols, copies are then taking into OSes for implementation purposes.

Quoted 37 lines
Quoted 10 lines
Quoted 9 lines

include/xen/interface/io/clkif.h

Quoted 5 lines
include/xen/interface/io/clkif.h new file +2 -0
+	unsigned long rate;
+	char clk_name[32];

Where does the frontend get these names from?  31 character names seems
rather limiting.

Quoted 5 lines

Indeed.

At a guess I would assume they come from the device-tree given to the guest
and tie into the host device tree.

Yeah. the clk_name is got from DomU dts, and in Dom0 there is also a same name.

Quoted 18 lines

I think a better model might be for each clk to have it's own subdirectory
under the overall clock bus node, e.g. something like:

/local/domain/<...>/clk/0/nr-clks = 4
/local/domain/<...>/clk/0/clk-0/ ...
/local/domain/<...>/clk/0/clk-1/ ...
/lo
cal/domain/<...>/clk/0/clk-2/ ...
/local/domain/<...>/clk/0/clk-3/ ...

and for each subdirectory to contain the a node containing the corresponding firmware table identifier (so path in the DT case), which the toolstack knows, so it can setup the f/e and b/e to correspond as necessary, and the f/e device needn't necessarily use the same name as the backend/host).

Quoted 5 lines
Quoted 2 lines

The request would then include the index and not the name (and as David observes the response only needs the id).

For now, I have not began the userspace libxl part for pvclk, I use the libxl pvusb code for test (:

Sure, but eventually this will need implementing in the toolstack and the protocol design should be what is most suitable for the usecase, not what happens to be most convenient for testing via some quick hack.

Quoted 3 lines

The id acctually means what operation is needed, such as CLK_PREPARE, CLK_UNPREPARE, CLK_SET_RATE, CLK_GET_RATE. I'll add more text to document this in V2.

Ah, then for consistency with other PV protocols I would suggest renaming your "id" as "cmd" and adding an "id" field which is simply echoed in the response to allow the frontend to match responses to requests.

Note however that the important thing in my paragraphs above was the decoupling of the naming from the f/e and b/e and avoiding the use of the DT specific path in the ring requests.

The PV protocol should ideally be independent of DT (lets assume we will want to use it for e.g. ACPI too), although there would probably in this case need to be a binding from the DT world to the pvclk world to allow the guest DT to remain consistent (i.e. so devices have something they can point at which can be resolved into a pvclk).

Quoted 14 lines
Quoted 6 lines

I'd also like to see a description of the DT bindings, which I assume must be needed such that the devices clocks property has something to refer to. For example maybe it doesn't make sense for xenstore to contain the path, but for the pvclk node in xenstore to contain the index.

The DT bindings for xen pvclk, I use this:
"

                clks: clks {
			compatible = "xen,xen-clk";
			#clock-cells = <1>;
			clock-output-names = "uart2_root_clk";
		};
Quoted 8 lines

"
the clock-output-names will be parsed and be registered as clk root. The device will use index to refer to the clk, as the following:
"

                clocks = <&clks 0>, <&clks 0>;
	        clock-names = "ipg", "per";

"
0 means the first one in clock-output-names.

This binding should be defined in Documentation/devicetree/Bindings in the usual way.

Quoted 6 lines

To the xenstore part, I am not sure whether need to expose the clock relate info to xenstore. I just want to store the clock names in xenstore to let
user know what clocks are now handled by DomU.

Quoted 6 lines

How about the following?

doamin1:
/local/domain/1/device/vclk/nr-clks
/local/domain/1/device/vclk/clk-0/name
/local/domain/1/device/vclk/clk-1/name

                             ^/0

Quoted 5 lines

domain2:
/local/domain/2/device/vclk/nr-clks
/local/domain/2/device/vclk/clk-0/name
/local/domain/2/device/vclk/clk-1/name

                             ^/0

Quoted 5 lines

domain0:
/local/domain/0/backend/vclk/1/0/nr-clks
/local/domain/0/backend/vclk/1/0/clk-0/name
/local/domain/0/backend/vclk/1/0/clk-1/name

Correct.

Quoted 3 lines

/local/domain/0/backend/vclk/1/1/nr-clks
/local/domain/0/backend/vclk/1/1/clk-0/name
/local/domain/0/backend/vclk/1/1/clk-1/name

Should be:
                              /2/0

In /local/domain/*/device/vclk/<N> the <N> is the devid or bus number (better to think of it as the latter in this case).

In /local/domain/<X>/backend/vclk/<Y>/<Z>/ you have:
X -- the backend domid (may not be 0 in all cases, needs to be planned for but not necessarily implemented)
Y -- the frontend domain
Z -- the devid/bus within frontend domain

Quoted 1 line

Or do not store the name and nr-clks in domain0?

The f/e directory should contain the identifier which the frontend needs to do the lookup from the firmware tables into pvclk space -- i.e. the name given in the f/e device tree node (maybe call it dt-name?).

The b/e directory should contain the name of the clock from the backend (i.e. host) pov i.e. the thing which needs to be looked up in the host firmware tables.

The two names are not necessarily the same, just as a thought experiment consider a DT using domU on an ACPI host or vice versa.

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

author
#10 lore raw
In reply to Ian Campbell

Hello Ian,

Quoted 26 lines · Ian Campbell
Quoted 10 lines · David Vrabel
Quoted 4 lines · Peng Fan

This patch was just a initial patch, not sure whether this way is ok from you side for handlding clk when doing platform device passhthrough. Any comments are appreciated, and your comments may give me a better direction.

There's no documentation on the interface, which makes it difficult to review.  At a first look it looks very specific to the particular Linux implementation of a clk subsystem.

Quoted 14 lines

include/xen/interface/io/clkif.h line 8

Quoted 11 lines
include/xen/interface/io/clkif.h new file +8 -0
@@ -0,0 +1,41 @@
+/*
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */

ABIs should be under a more permissive license so they can be used by other (non-GPLv2) operating systems.

Quoted 3 lines

... along the same lines proposals for new ABIs should be made in the form of patches to xen.git:xen/include/public/io/ before being submitted as an implementation for one particular os.

I had no idea about this before. Do you mean that before I implement pvclk for linux, I need to first post the clkif part to xen devel?

If it is, I'll split the interface part and send this part to [email protected] for review.

Quoted 8 lines
Quoted 7 lines

include/xen/interface/io/clkif.h line 10

Quoted 4 lines
include/xen/interface/io/clkif.h new file +2 -0
+	unsigned long rate;
+	char clk_name[32];

Where does the frontend get these names from?  31 character names seems rather limiting.

Quoted 4 lines

Indeed.

At a guess I would assume they come from the device-tree given to the guest and tie into the host device tree.

Yeah. the clk_name is got from DomU dts, and in Dom0 there is also a same name.

Quoted 11 lines

I think a better model might be for each clk to have it's own subdirectory under the overall clock bus node, e.g. something like:

/local/domain/<...>/clk/0/nr-clks = 4
/local/domain/<...>/clk/0/clk-0/ ...
/local/domain/<...>/clk/0/clk-1/ ...
/lo
cal/domain/<...>/clk/0/clk-2/ ...
/local/domain/<...>/clk/0/clk-3/ ...

Quoted 3 lines

and for each subdirectory to contain the a node containing the corresponding firmware table identifier (so path in the DT case), which the toolstack knows, so it can setup the f/e and b/e to correspond as necessary, and the f/e device needn't necessarily use the same name as the backend/host).

The request would then include the index and not the name (and as David observes the response only needs the id).

For now, I have not began the userspace libxl part for pvclk, I use the libxl pvusb code for test (:
The id acctually means what operation is needed, such as CLK_PREPARE, CLK_UNPREPARE, CLK_SET_RATE, CLK_GET_RATE. I'll add more text to document this in V2.

Quoted 3 lines

As well as properly documenting the meaning of the operations
the clkif.h should also define the xenstore nodes and contain the binary layouts of the req/rsp structs (see netif.h for examples of both, blkif.h also includes examples of the former).

ok. I'll take netif/blkif for reference.

Quoted 2 lines

I'd also like to see a description of the DT bindings, which I assume must be needed such that the devices clocks property has something to refer to. For example maybe it doesn't make sense for xenstore to contain the path, but for the pvclk node in xenstore to contain the index.

The DT bindings for xen pvclk, I use this:
"

                clks: clks {
			compatible = "xen,xen-clk";
			#clock-cells = <1>;
			clock-output-names = "uart2_root_clk";
		};
"
the clock-output-names will be parsed and be registered as clk root. The device will use index to refer to the clk, as the following:
"
                clocks = <&clks 0>, <&clks 0>;
	        clock-names = "ipg", "per";

"
0 means the first one in clock-output-names.

To the xenstore part, I am not sure whether need to expose the clock relate info to xenstore. I just want to store the clock names in xenstore to let user know what clocks are now handled by DomU.

How about the following?

doamin1:
/local/domain/1/device/vclk/nr-clks
/local/domain/1/device/vclk/clk-0/name
/local/domain/1/device/vclk/clk-1/name

domain2:
/local/domain/2/device/vclk/nr-clks
/local/domain/2/device/vclk/clk-0/name
/local/domain/2/device/vclk/clk-1/name

domain0:
/local/domain/0/backend/vclk/1/0/nr-clks
/local/domain/0/backend/vclk/1/0/clk-0/name
/local/domain/0/backend/vclk/1/0/clk-1/name
/local/domain/0/backend/vclk/1/1/nr-clks
/local/domain/0/backend/vclk/1/1/clk-0/name
/local/domain/0/backend/vclk/1/1/clk-1/name

Or do not store the name and nr-clks in domain0?

Thanks,
Peng.

Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
include/xen/interface/io/clkif.h new file +2 -0
+
+DEFINE_RING_TYPES(xen_clkif, struct xen_clkif_request, struct

xen_clkif_response);

include/xen/interface/io/clkif.h new file +3 -0
+#define XEN_CLK_RING_SIZE __CONST_RING_SIZE(xen_clkif, PAGE_SIZE)
+
+#endif
#11 lore raw
In reply to David Vrabel
Quoted 10 lines · David Vrabel
Quoted 4 lines · Peng Fan

This patch was just a initial patch, not sure whether this way is ok from you side for handlding clk when doing platform device passhthrough. Any comments are appreciated, and your comments may give me a better direction.

There's no documentation on the interface, which makes it difficult to review.  At a first look it looks very specific to the particular Linux implementation of a clk subsystem.

Quoted 14 lines

include/xen/interface/io/clkif.h line 8

Quoted 11 lines
include/xen/interface/io/clkif.h new file +8 -0
@@ -0,0 +1,41 @@
+/*
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */

ABIs should be under a more permissive license so they can be used by other (non-GPLv2) operating systems.

... along the same lines proposals for new ABIs should be made in the form of patches to xen.git:xen/include/public/io/ before being submitted as an implementation for one particular os.

Quoted 5 lines

include/xen/interface/io/clkif.h line 10

Quoted 2 lines
include/xen/interface/io/clkif.h new file +2 -0
+	unsigned long rate;
+	char clk_name[32];

Where does the frontend get these names from?  31 character names seems rather limiting.

Indeed.

At a guess I would assume they come from the device-tree given to the guest and tie into the host device tree.

I think a better model might be for each clk to have it's own subdirectory under the overall clock bus node, e.g. something like:

/local/domain/<...>/clk/0/nr-clks = 4
/local/domain/<...>/clk/0/clk-0/ ...
/local/domain/<...>/clk/0/clk-1/ ...
/lo
cal/domain/<...>/clk/0/clk-2/ ...
/local/domain/<...>/clk/0/clk-3/ ...

and for each subdirectory to contain the a node containing the corresponding firmware table identifier (so path in the DT case), which the toolstack knows, so it can setup the f/e and b/e to correspond as necessary, and the f/e device needn't necessarily use the same name as the backend/host).

The request would then include the index and not the name (and as David observes the response only needs the id).

As well as properly documenting the meaning of the operations
the clkif.h should also define the xenstore nodes and contain the binary layouts of the req/rsp structs (see netif.h for examples of both, blkif.h also includes examples of the former).

I'd also like to see a description of the DT bindings, which I assume must be needed such that the devices clocks property has something to refer to. For example maybe it doesn't make sense for xenstore to contain the path, but for the pvclk node in xenstore to contain the index.

Quoted 8 lines

include/xen/interface/io/clkif.h line 41

Quoted 7 lines
include/xen/interface/io/clkif.h new file +2 -0
+
+DEFINE_RING_TYPES(xen_clkif, struct xen_clkif_request, struct

xen_clkif_response);

include/xen/interface/io/clkif.h new file +3 -0
+#define XEN_CLK_RING_SIZE __CONST_RING_SIZE(xen_clkif, PAGE_SIZE)
+
+#endif

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

author
#12 lore raw
In reply to David Vrabel

Hello David,

Quoted 9 lines · David Vrabel
Quoted 4 lines · Peng Fan

This patch was just a initial patch, not sure whether this way is ok from you side for handlding clk when doing platform device passhthrough. Any comments are appreciated, and your comments may give me a better direction.

There's no documentation on the interface, which makes it difficult to review. At a first look it looks very specific to the particular Linux implementation of a clk subsystem.

My bad. I'll add more text in commit log or cover letter in V2 to describe the interface.

Quoted 15 lines

include/xen/interface/io/clkif.h line 8

Quoted 12 lines
include/xen/interface/io/clkif.h new file +8 -0
@@ -0,0 +1,41 @@
+/*
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */

ABIs should be under a more permissive license so they can be used by other (non-GPLv2) operating systems.

ok. I'll change this.

Quoted 14 lines
Quoted 14 lines
include/xen/interface/io/clkif.h new file +13 -0
+
+#ifndef __XEN_PUBLIC_IO_CLKIF_H__
+#define __XEN_PUBLIC_IO_CLKIF_H__
+
+#include <xen/interface/io/ring.h>
+#include <xen/interface/grant_table.h>
+
+/**/
+enum {
+	XENCLK_PREPARE,		/* clk_prepare_enable */
+	XENCLK_UNPREPARE,	/* clk_unprepare_disable */
+	XENCLK_GET_RATE,	/* clk_get_rate */
+	XENCLK_SET_RATE,	/* clk_set_rate */
Quoted 8 lines

include/xen/interface/io/clkif.h line 26

Quoted 5 lines
include/xen/interface/io/clkif.h new file +5 -0
+	XENCLK_END,
+};
+
+struct xen_clkif_request {
+	int id;

You should use fixed width types so the ABI is the same on 32-bit and 64-bit guests.

Will fix in V2.

Quoted 6 lines

include/xen/interface/io/clkif.h line 28

Quoted 3 lines
include/xen/interface/io/clkif.h new file +2 -0
+	unsigned long rate;
+	char clk_name[32];

Where does the frontend get these names from? 31 character names seems rather limiting.

The clk_name is got from DomU device tree. In the commit log, I wrote this:
"

                clks: clks {
			compatible = "xen,xen-clk";
			#clock-cells = <1>;
			clock-output-names = "uart2_root_clk";
		};

"
The clk_name is one of the entry from clock-output-names, clk_name will be passed to Dom0, Dom0 will use the clk_name to find the clk structure using __clk_lookup.

Quoted 12 lines

include/xen/interface/io/clkif.h line 36

Quoted 9 lines
include/xen/interface/io/clkif.h new file +8 -0
+};
+
+struct xen_clkif_response {
+	int id;
+	int success;
+	unsigned long rate;
+	char clk_name[32];
+};

I don't think you need to the name in the response. The id will tie the response to the request.

My original idea is to use id and clk_name to check whether the response is for the requester. You can see in the patch:
" if ((id == comp->id) && !strncmp(name, comp->clk_name, sizeof(comp->clk_name)))"

Maybe clk_name is redundant here. I will remove it in V2.

Thanks for your comments.

Peng.

Quoted 8 lines
Quoted 7 lines
include/xen/interface/io/clkif.h new file +5 -0
+
+DEFINE_RING_TYPES(xen_clkif, struct xen_clkif_request, struct xen_clkif_response);
+#define XEN_CLK_RING_SIZE __CONST_RING_SIZE(xen_clkif, PAGE_SIZE)
+
+#endif
author
#13 lore raw
In reply to David Vrabel

Hello David,

Quoted 9 lines · David Vrabel
Quoted 4 lines · Peng Fan

This patch was just a initial patch, not sure whether this way is ok from you side for handlding clk when doing platform device passhthrough. Any comments are appreciated, and your comments may give me a better direction.

There's no documentation on the interface, which makes it difficult to review. At a first look it looks very specific to the particular Linux implementation of a clk subsystem.

My bad. I'll add more text in commit log or cover letter in V2 to describe the interface.

Quoted 15 lines

include/xen/interface/io/clkif.h line 8

Quoted 12 lines
include/xen/interface/io/clkif.h new file +8 -0
@@ -0,0 +1,41 @@
+/*
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */

ABIs should be under a more permissive license so they can be used by other (non-GPLv2) operating systems.

ok. I'll change this.

Quoted 14 lines
Quoted 14 lines
include/xen/interface/io/clkif.h new file +13 -0
+
+#ifndef __XEN_PUBLIC_IO_CLKIF_H__
+#define __XEN_PUBLIC_IO_CLKIF_H__
+
+#include <xen/interface/io/ring.h>
+#include <xen/interface/grant_table.h>
+
+/**/
+enum {
+	XENCLK_PREPARE,		/* clk_prepare_enable */
+	XENCLK_UNPREPARE,	/* clk_unprepare_disable */
+	XENCLK_GET_RATE,	/* clk_get_rate */
+	XENCLK_SET_RATE,	/* clk_set_rate */
Quoted 8 lines

include/xen/interface/io/clkif.h line 26

Quoted 5 lines
include/xen/interface/io/clkif.h new file +5 -0
+	XENCLK_END,
+};
+
+struct xen_clkif_request {
+	int id;

You should use fixed width types so the ABI is the same on 32-bit and 64-bit guests.

Will fix in V2.

Quoted 6 lines

include/xen/interface/io/clkif.h line 28

Quoted 3 lines
include/xen/interface/io/clkif.h new file +2 -0
+	unsigned long rate;
+	char clk_name[32];

Where does the frontend get these names from? 31 character names seems rather limiting.

The clk_name is got from DomU device tree. In the commit log, I wrote this:
"

                clks: clks {
			compatible = "xen,xen-clk";
			#clock-cells = <1>;
			clock-output-names = "uart2_root_clk";
		};

"
The clk_name is one of the entry from clock-output-names, clk_name will be passed to Dom0, Dom0 will use the clk_name to find the clk structure using __clk_lookup.

Quoted 12 lines

include/xen/interface/io/clkif.h line 36

Quoted 9 lines
include/xen/interface/io/clkif.h new file +8 -0
+};
+
+struct xen_clkif_response {
+	int id;
+	int success;
+	unsigned long rate;
+	char clk_name[32];
+};

I don't think you need to the name in the response. The id will tie the response to the request.

My original idea is to use id and clk_name to check whether the response is for the requester. You can see in the patch:
" if ((id == comp->id) && !strncmp(name, comp->clk_name, sizeof(comp->clk_name)))"

Maybe clk_name is redundant here. I will remove it in V2.

Thanks for your comments.

Peng.

Quoted 8 lines
Quoted 7 lines
include/xen/interface/io/clkif.h new file +5 -0
+
+DEFINE_RING_TYPES(xen_clkif, struct xen_clkif_request, struct xen_clkif_response);
+#define XEN_CLK_RING_SIZE __CONST_RING_SIZE(xen_clkif, PAGE_SIZE)
+
+#endif
#14 lore raw
In reply to Peng Fan
Quoted 4 lines · Peng Fan

This patch was just a initial patch, not sure whether this way is ok from you side for handlding clk when doing platform device passhthrough. Any comments are appreciated, and your comments may give me a better direction.

There's no documentation on the interface, which makes it difficult to review. At a first look it looks very specific to the particular Linux implementation of a clk subsystem.

include/xen/interface/io/clkif.h line 8

Quoted 11 lines
include/xen/interface/io/clkif.h new file +8 -0
@@ -0,0 +1,41 @@
+/*
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */

ABIs should be under a more permissive license so they can be used by other (non-GPLv2) operating systems.

Quoted 8 lines
include/xen/interface/io/clkif.h new file +8 -0
+
+#ifndef __XEN_PUBLIC_IO_CLKIF_H__
+#define __XEN_PUBLIC_IO_CLKIF_H__
+
+#include <xen/interface/io/ring.h>
+#include <xen/interface/grant_table.h>
+
+/**/

include/xen/interface/io/clkif.h line 26

Quoted 10 lines
include/xen/interface/io/clkif.h new file +10 -0
+enum {
+	XENCLK_PREPARE,		/* clk_prepare_enable */
+	XENCLK_UNPREPARE,	/* clk_unprepare_disable */
+	XENCLK_GET_RATE,	/* clk_get_rate */
+	XENCLK_SET_RATE,	/* clk_set_rate */
+	XENCLK_END,
+};
+
+struct xen_clkif_request {
+	int id;

You should use fixed width types so the ABI is the same on 32-bit and 64-bit guests.

include/xen/interface/io/clkif.h line 28

Quoted 2 lines
include/xen/interface/io/clkif.h new file +2 -0
+	unsigned long rate;
+	char clk_name[32];

Where does the frontend get these names from? 31 character names seems rather limiting.

include/xen/interface/io/clkif.h line 36

Quoted 8 lines
include/xen/interface/io/clkif.h new file +8 -0
+};
+
+struct xen_clkif_response {
+	int id;
+	int success;
+	unsigned long rate;
+	char clk_name[32];
+};

I don't think you need to the name in the response. The id will tie the response to the request.

Quoted 6 lines
include/xen/interface/io/clkif.h new file +5 -0
+
+DEFINE_RING_TYPES(xen_clkif, struct xen_clkif_request, struct xen_clkif_response);
+#define XEN_CLK_RING_SIZE __CONST_RING_SIZE(xen_clkif, PAGE_SIZE)
+
+#endif