Skip to contentSkip to conversation

xen/arm: enable clocks used by the hypervisor

PATCH Superseded Dirk Behme 3 participants 15 messages Jul 8, 2016 – Jul 12, 2016

Subsystems (4)
lore
Share & tools
lore

Dirk Behme

author
#0 lore raw

PATCH v3 1/1 xen/arm: enable clocks used by the hypervisor

Xen hypervisor drivers might replace native OS drivers. The result is that some important clocks that are enabled by the OS in the non-Xen case are not properly enabled in the presence of Xen. The clocks property enumerates the clocks that must be enabled by the Xen clock consumer.

An example is a serial driver enabled by the hypervisor. Xen must consume and enable these clocks in the OS to ensure behavior continues after firmware configures the UART hardware and corresponding clock harder.

Up to now, the workaround for this has been to use the Linux kernel command line parameter 'clk_ignore_unused'. See Xen bug

http://bugs.xenproject.org/xen/bug/45

too.

To fix this, we will add the "unused" clocks in Xen to the hypervisor node. The OS has to consume and enable the clocks from the hypervisor node, then.

Therefore, check if there is a "clocks" entry in the hypervisor node and if so consume and enable the given clocks. This prevents the clocks from being disabled by the OS.

---
Changes in v3: Use the xen.txt description proposed by Michael. Thanks!

Changes in v2: Drop the Linux implementation details like clk_disable_unused
in xen.txt.

 Documentation/devicetree/bindings/arm/xen.txt | 13 ++++++++
 arch/arm/xen/enlighten.c                      | 47 +++++++++++++++++++++++++++
 2 files changed, 60 insertions(+)
Documentation/devicetree/bindings/arm/xen.txt +13 -0
index c9b9321..00f2165 100644
@@ -17,6 +17,19 @@ the following properties:
   A GIC node is also required.
   This property is unnecessary when booting Dom0 using ACPI.
 
+Optional properties:
+
+clocks: one or more clocks to be enabled
+  Xen hypervisor drivers might replace native OS drivers. The result is
+  that some important clocks that are enabled by the OS in the non-Xen
+  case are not properly enabled in the presence of Xen. The clocks
+  property enumerates the clocks that must be enabled by the Xen clock
+  consumer.
+  An example is a serial driver enabled by the hypervisor. Xen must
+  consume and enable these clocks in the OS to ensure behavior continues
+  after firmware configures the UART hardware and corresponding clock
+  harder.
+
 To support UEFI on Xen ARM virtual platforms, Xen populates the FDT "uefi" node
 under /hypervisor with following parameters:
 
arch/arm/xen/enlighten.c +47 -0

59 lines not on this page · raw message

Signature · 1 line
2.8.0
#1 lore raw

PATCH v3 1/1 xen/arm: enable clocks used by the hypervisor

Hi Dirk,

Quoted 7 lines · Dirk Behme

Xen hypervisor drivers might replace native OS drivers. The result is that some important clocks that are enabled by the OS in the non-Xen case are not properly enabled in the presence of Xen. The clocks property enumerates the clocks that must be enabled by the Xen clock consumer.

An example is a serial driver enabled by the hypervisor. Xen must

I would say "An example is the UART used by the hypervisor."

Quoted 3 lines

consume and enable these clocks in the OS to ensure behavior continues after firmware configures the UART hardware and corresponding clock harder.

What do you mean by "harder"?

Also, relying on DOM0 to enable the clock looks very wrong to me and you give an example which prove that. The UART will be used before hand by Xen, however it will not be possible to use it if you expect DOM0 to enable the clock (or even modify the clock frequency).

The clock should be enabled either by the firmware or Xen. But not DOM0. DOM0 should not touch this clock at all.

Furthermore, this property could be used for clock associated to device that will be passthrough-ed to a guest. In this case, the clock would be enabled even if the device is not in use which will result more power consumption.

Quoted 32 lines

Up to now, the workaround for this has been to use the Linux kernel command line parameter 'clk_ignore_unused'. See Xen bug

http://bugs.xenproject.org/xen/bug/45

too.

To fix this, we will add the "unused" clocks in Xen to the hypervisor node. The OS has to consume and enable the clocks from the hypervisor node, then.

Therefore, check if there is a "clocks" entry in the hypervisor node and if so consume and enable the given clocks. This prevents the clocks from being disabled by the OS.

---
Changes in v3: Use the xen.txt description proposed by Michael. Thanks!

Changes in v2: Drop the Linux implementation details like clk_disable_unused
in xen.txt.

  Documentation/devicetree/bindings/arm/xen.txt | 13 ++++++++
  arch/arm/xen/enlighten.c                      | 47 +++++++++++++++++++++++++++
  2 files changed, 60 insertions(+)
Documentation/devicetree/bindings/arm/xen.txt +0 -0
index c9b9321..00f2165 100644

Documentation/devicetree/bindings/arm/xen.txt the following properties: · line 23

Quoted 7 lines
Documentation/devicetree/bindings/arm/xen.txt +4 -0
@@ -17,6 +17,19 @@ the following properties:
    A GIC node is also required.
    This property is unnecessary when booting Dom0 using ACPI.
 
+Optional properties:
+
+clocks: one or more clocks to be enabled
+  Xen hypervisor drivers might replace native OS drivers. The result is

"native OS" has no meaning on Xen. This seems to be a cumbersome way to say that the device will be used by the hypervisor and hidden to DOM0 (aka hardware domain).

Documentation/devicetree/bindings/arm/xen.txt the following properties: · line 34

Quoted 11 lines
Documentation/devicetree/bindings/arm/xen.txt +9 -0
+  that some important clocks that are enabled by the OS in the non-Xen
+  case are not properly enabled in the presence of Xen. The clocks
+  property enumerates the clocks that must be enabled by the Xen clock
+  consumer.
+  An example is a serial driver enabled by the hypervisor. Xen must
+  consume and enable these clocks in the OS to ensure behavior continues
+  after firmware configures the UART hardware and corresponding clock
+  harder.
+
  To support UEFI on Xen ARM virtual platforms, Xen populates the FDT "uefi" node
  under /hypervisor with following parameters:

Regards,

Signature · 1 line
Julien Grall
author
#2 lore raw

PATCH v3 1/1 xen/arm: enable clocks used by the hypervisor

Hi Michael and Julien,

Quoted 24 lines · Julien Grall

Hi Dirk,

Quoted 7 lines · Dirk Behme

Xen hypervisor drivers might replace native OS drivers. The result is that some important clocks that are enabled by the OS in the non-Xen case are not properly enabled in the presence of Xen. The clocks property enumerates the clocks that must be enabled by the Xen clock consumer.

An example is a serial driver enabled by the hypervisor. Xen must

I would say "An example is the UART used by the hypervisor."

Quoted 3 lines

consume and enable these clocks in the OS to ensure behavior continues after firmware configures the UART hardware and corresponding clock harder.

What do you mean by "harder"?

Also, relying on DOM0 to enable the clock looks very wrong to me and you give an example which prove that. The UART will be used before hand by Xen, however it will not be possible to use it if you expect DOM0 to enable the clock (or even modify the clock frequency).

Quoted 7 lines

The clock should be enabled either by the firmware or Xen. But not DOM0. DOM0 should not touch this clock at all.

Furthermore, this property could be used for clock associated to device that will be passthrough-ed to a guest. In this case, the clock would be enabled even if the device is not in use which will result more power consumption.

I took the description directly from Michael's proposal

http://www.spinics.net/lists/arm-kernel/msg516576.html

Would it be possible that you two experts agree on the exact wording you like to see?

Best regards

Dirk

Quoted 61 lines
Quoted 34 lines

Up to now, the workaround for this has been to use the Linux kernel command line parameter 'clk_ignore_unused'. See Xen bug

http://bugs.xenproject.org/xen/bug/45

too.

To fix this, we will add the "unused" clocks in Xen to the hypervisor node. The OS has to consume and enable the clocks from the hypervisor node, then.

Therefore, check if there is a "clocks" entry in the hypervisor node and if so consume and enable the given clocks. This prevents the clocks from being disabled by the OS.

---
Changes in v3: Use the xen.txt description proposed by Michael. Thanks!

Changes in v2: Drop the Linux implementation details like clk_disable_unused
in xen.txt.

  Documentation/devicetree/bindings/arm/xen.txt | 13 ++++++++
  arch/arm/xen/enlighten.c                      | 47
+++++++++++++++++++++++++++
  2 files changed, 60 insertions(+)
Documentation/devicetree/bindings/arm/xen.txt +0 -0
index c9b9321..00f2165 100644

Documentation/devicetree/bindings/arm/xen.txt the following properties: · line 23

Quoted 7 lines
Documentation/devicetree/bindings/arm/xen.txt +4 -0
@@ -17,6 +17,19 @@ the following properties:
    A GIC node is also required.
    This property is unnecessary when booting Dom0 using ACPI.
 
+Optional properties:
+
+clocks: one or more clocks to be enabled
+  Xen hypervisor drivers might replace native OS drivers. The result is

"native OS" has no meaning on Xen. This seems to be a cumbersome way to say that the device will be used by the hypervisor and hidden to DOM0 (aka hardware domain).

Quoted 10 lines
Documentation/devicetree/bindings/arm/xen.txt +9 -0
+  that some important clocks that are enabled by the OS in the non-Xen
+  case are not properly enabled in the presence of Xen. The clocks
+  property enumerates the clocks that must be enabled by the Xen clock
+  consumer.
+  An example is a serial driver enabled by the hypervisor. Xen must
+  consume and enable these clocks in the OS to ensure behavior continues
+  after firmware configures the UART hardware and corresponding clock
+  harder.
+
  To support UEFI on Xen ARM virtual platforms, Xen populates the FDT
Quoted 2 lines

"uefi" node
under /hypervisor with following parameters:

Regards,

#3 lore raw

PATCH v3 1/1 xen/arm: enable clocks used by the hypervisor

Quoted 36 lines · Dirk Behme

Hi Michael and Julien,

Quoted 24 lines · Julien Grall

Hi Dirk,

Quoted 7 lines · Dirk Behme

Xen hypervisor drivers might replace native OS drivers. The result is that some important clocks that are enabled by the OS in the non-Xen case are not properly enabled in the presence of Xen. The clocks property enumerates the clocks that must be enabled by the Xen clock consumer.

An example is a serial driver enabled by the hypervisor. Xen must

I would say "An example is the UART used by the hypervisor."

Quoted 3 lines

consume and enable these clocks in the OS to ensure behavior continues after firmware configures the UART hardware and corresponding clock harder.

What do you mean by "harder"?

Also, relying on DOM0 to enable the clock looks very wrong to me and you give an example which prove that. The UART will be used before hand by Xen, however it will not be possible to use it if you expect DOM0 to enable the clock (or even modify the clock frequency).

Quoted 7 lines

The clock should be enabled either by the firmware or Xen. But not DOM0. DOM0 should not touch this clock at all.

Furthermore, this property could be used for clock associated to device that will be passthrough-ed to a guest. In this case, the clock would be enabled even if the device is not in use which will result more power consumption.

Quoted 6 lines

I took the description directly from Michael's proposal

http://www.spinics.net/lists/arm-kernel/msg516576.html

Would it be possible that you two experts agree on the exact wording you like to see?

I think the wording suggested by Mark in [1] represents better what we would like to achieve with this property.

Regards,

[1] https://www.spinics.net/lists/arm-kernel/msg516158.html

Signature · 1 line
Julien Grall
#4 lore raw

PATCH v3 1/1 xen/arm: enable clocks used by the hypervisor

Quoting Julien Grall (2016-07-08 03:49:33)

Quoted 41 lines · Dirk Behme
Quoted 38 lines

Hi Michael and Julien,

Quoted 24 lines · Julien Grall

Hi Dirk,

Quoted 7 lines · Dirk Behme

Xen hypervisor drivers might replace native OS drivers. The result is that some important clocks that are enabled by the OS in the non-Xen case are not properly enabled in the presence of Xen. The clocks property enumerates the clocks that must be enabled by the Xen clock consumer.

An example is a serial driver enabled by the hypervisor. Xen must

I would say "An example is the UART used by the hypervisor."

Quoted 3 lines

consume and enable these clocks in the OS to ensure behavior continues after firmware configures the UART hardware and corresponding clock harder.

What do you mean by "harder"?

Also, relying on DOM0 to enable the clock looks very wrong to me and you give an example which prove that. The UART will be used before hand by Xen, however it will not be possible to use it if you expect DOM0 to enable the clock (or even modify the clock frequency).

Quoted 7 lines

The clock should be enabled either by the firmware or Xen. But not DOM0. DOM0 should not touch this clock at all.

Furthermore, this property could be used for clock associated to device that will be passthrough-ed to a guest. In this case, the clock would be enabled even if the device is not in use which will result more power consumption.

I took the description directly from Michael's proposal

Quoted 7 lines
Quoted 4 lines

http://www.spinics.net/lists/arm-kernel/msg516576.html

Would it be possible that you two experts agree on the exact wording you like to see?

I think the wording suggested by Mark in [1] represents better what we would like to achieve with this property.

Mark's copy is fine by me. The main thing is to avoid talking about "unused" clocks being disabled by the OS. If you have need clocks to be enabled, then you simply claim them and enable them. All of the other stuff is just noise.

Regards,
Mike

Quoted 7 lines

Regards,

[1] https://www.spinics.net/lists/arm-kernel/msg516158.html

Signature · 1 line
Julien Grall
#5 lore raw
In reply to Julien Grall

Quoting Julien Grall (2016-07-08 03:49:33)

Quoted 41 lines · Dirk Behme
Quoted 38 lines

Hi Michael and Julien,

Quoted 24 lines · Julien Grall

Hi Dirk,

Quoted 7 lines · Dirk Behme

Xen hypervisor drivers might replace native OS drivers. The result is that some important clocks that are enabled by the OS in the non-Xen case are not properly enabled in the presence of Xen. The clocks property enumerates the clocks that must be enabled by the Xen clock consumer.

An example is a serial driver enabled by the hypervisor. Xen must

I would say "An example is the UART used by the hypervisor."

Quoted 3 lines

consume and enable these clocks in the OS to ensure behavior continues after firmware configures the UART hardware and corresponding clock harder.

What do you mean by "harder"?

Also, relying on DOM0 to enable the clock looks very wrong to me and you give an example which prove that. The UART will be used before hand by Xen, however it will not be possible to use it if you expect DOM0 to enable the clock (or even modify the clock frequency).

Quoted 7 lines

The clock should be enabled either by the firmware or Xen. But not DOM0. DOM0 should not touch this clock at all.

Furthermore, this property could be used for clock associated to device that will be passthrough-ed to a guest. In this case, the clock would be enabled even if the device is not in use which will result more power consumption.

I took the description directly from Michael's proposal

Quoted 7 lines
Quoted 4 lines

http://www.spinics.net/lists/arm-kernel/msg516576.html

Would it be possible that you two experts agree on the exact wording you like to see?

I think the wording suggested by Mark in [1] represents better what we would like to achieve with this property.

Mark's copy is fine by me. The main thing is to avoid talking about "unused" clocks being disabled by the OS. If you have need clocks to be enabled, then you simply claim them and enable them. All of the other stuff is just noise.

Regards,
Mike

Quoted 7 lines

Regards,

[1] https://www.spinics.net/lists/arm-kernel/msg516158.html

Signature · 1 line
Julien Grall

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

#6 lore raw
In reply to Dirk Behme
Quoted 36 lines · Dirk Behme

Hi Michael and Julien,

Quoted 24 lines · Julien Grall

Hi Dirk,

Quoted 7 lines · Dirk Behme

Xen hypervisor drivers might replace native OS drivers. The result is that some important clocks that are enabled by the OS in the non-Xen case are not properly enabled in the presence of Xen. The clocks property enumerates the clocks that must be enabled by the Xen clock consumer.

An example is a serial driver enabled by the hypervisor. Xen must

I would say "An example is the UART used by the hypervisor."

Quoted 3 lines

consume and enable these clocks in the OS to ensure behavior continues after firmware configures the UART hardware and corresponding clock harder.

What do you mean by "harder"?

Also, relying on DOM0 to enable the clock looks very wrong to me and you give an example which prove that. The UART will be used before hand by Xen, however it will not be possible to use it if you expect DOM0 to enable the clock (or even modify the clock frequency).

Quoted 7 lines

The clock should be enabled either by the firmware or Xen. But not DOM0. DOM0 should not touch this clock at all.

Furthermore, this property could be used for clock associated to device that will be passthrough-ed to a guest. In this case, the clock would be enabled even if the device is not in use which will result more power consumption.

Quoted 6 lines

I took the description directly from Michael's proposal

http://www.spinics.net/lists/arm-kernel/msg516576.html

Would it be possible that you two experts agree on the exact wording you like to see?

I think the wording suggested by Mark in [1] represents better what we would like to achieve with this property.

Regards,

[1] https://www.spinics.net/lists/arm-kernel/msg516158.html

Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
author
#7 lore raw
In reply to Julien Grall

Hi Michael and Julien,

Quoted 24 lines · Julien Grall

Hi Dirk,

Quoted 7 lines · Dirk Behme

Xen hypervisor drivers might replace native OS drivers. The result is that some important clocks that are enabled by the OS in the non-Xen case are not properly enabled in the presence of Xen. The clocks property enumerates the clocks that must be enabled by the Xen clock consumer.

An example is a serial driver enabled by the hypervisor. Xen must

I would say "An example is the UART used by the hypervisor."

Quoted 3 lines

consume and enable these clocks in the OS to ensure behavior continues after firmware configures the UART hardware and corresponding clock harder.

What do you mean by "harder"?

Also, relying on DOM0 to enable the clock looks very wrong to me and you give an example which prove that. The UART will be used before hand by Xen, however it will not be possible to use it if you expect DOM0 to enable the clock (or even modify the clock frequency).

Quoted 7 lines

The clock should be enabled either by the firmware or Xen. But not DOM0. DOM0 should not touch this clock at all.

Furthermore, this property could be used for clock associated to device that will be passthrough-ed to a guest. In this case, the clock would be enabled even if the device is not in use which will result more power consumption.

I took the description directly from Michael's proposal

http://www.spinics.net/lists/arm-kernel/msg516576.html

Would it be possible that you two experts agree on the exact wording you like to see?

Best regards

Dirk

Quoted 59 lines
Quoted 34 lines

Up to now, the workaround for this has been to use the Linux kernel command line parameter 'clk_ignore_unused'. See Xen bug

http://bugs.xenproject.org/xen/bug/45

too.

To fix this, we will add the "unused" clocks in Xen to the hypervisor node. The OS has to consume and enable the clocks from the hypervisor node, then.

Therefore, check if there is a "clocks" entry in the hypervisor node and if so consume and enable the given clocks. This prevents the clocks from being disabled by the OS.

---
Changes in v3: Use the xen.txt description proposed by Michael. Thanks!

Changes in v2: Drop the Linux implementation details like clk_disable_unused
in xen.txt.

  Documentation/devicetree/bindings/arm/xen.txt | 13 ++++++++
  arch/arm/xen/enlighten.c                      | 47
+++++++++++++++++++++++++++
  2 files changed, 60 insertions(+)
Documentation/devicetree/bindings/arm/xen.txt +0 -0
index c9b9321..00f2165 100644

Documentation/devicetree/bindings/arm/xen.txt the following properties: · line 23

Quoted 7 lines
Documentation/devicetree/bindings/arm/xen.txt +4 -0
@@ -17,6 +17,19 @@ the following properties:
    A GIC node is also required.
    This property is unnecessary when booting Dom0 using ACPI.
 
+Optional properties:
+
+clocks: one or more clocks to be enabled
+  Xen hypervisor drivers might replace native OS drivers. The result is

"native OS" has no meaning on Xen. This seems to be a cumbersome way to say that the device will be used by the hypervisor and hidden to DOM0 (aka hardware domain).

Quoted 10 lines
Documentation/devicetree/bindings/arm/xen.txt +9 -0
+  that some important clocks that are enabled by the OS in the non-Xen
+  case are not properly enabled in the presence of Xen. The clocks
+  property enumerates the clocks that must be enabled by the Xen clock
+  consumer.
+  An example is a serial driver enabled by the hypervisor. Xen must
+  consume and enable these clocks in the OS to ensure behavior continues
+  after firmware configures the UART hardware and corresponding clock
+  harder.
+
  To support UEFI on Xen ARM virtual platforms, Xen populates the FDT
Quoted 2 lines

"uefi" node
under /hypervisor with following parameters:

Quoted 2 lines

Regards,

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

#8 lore raw

PATCH v3 1/1 xen/arm: enable clocks used by the hypervisor

In reply to Julien Grall

Quoting Julien Grall (2016-07-08 02:34:43)

Quoted 24 lines

Hi Dirk,

Quoted 7 lines · Dirk Behme

Xen hypervisor drivers might replace native OS drivers. The result is that some important clocks that are enabled by the OS in the non-Xen case are not properly enabled in the presence of Xen. The clocks property enumerates the clocks that must be enabled by the Xen clock consumer.

An example is a serial driver enabled by the hypervisor. Xen must

I would say "An example is the UART used by the hypervisor."

Quoted 3 lines

consume and enable these clocks in the OS to ensure behavior continues after firmware configures the UART hardware and corresponding clock harder.

What do you mean by "harder"?

Also, relying on DOM0 to enable the clock looks very wrong to me and you give an example which prove that. The UART will be used before hand by Xen, however it will not be possible to use it if you expect DOM0 to enable the clock (or even modify the clock frequency).

Quoted 7 lines

The clock should be enabled either by the firmware or Xen. But not DOM0. DOM0 should not touch this clock at all.

Furthermore, this property could be used for clock associated to device that will be passthrough-ed to a guest. In this case, the clock would be enabled even if the device is not in use which will result more power consumption.

Is there a need to pass clock references through to guests? If so the unmerged CLK_ENABLE_HAND_OFF[0] feature might be useful to you? If this flag is set on a given clk, it will be enabled at the time it is registered by the clk provider driver, and it's enable_count reference counter will be "handed off" to the first consumer that calls clk_get() and clk_prepare_enable() on it. This means the clock CAN be gated by it's proper driver, but it will be enabled at boot time as well.

This is useful for use cases like splash screens where the bootloader configures the display and plays some animation, and we want the linux kernel to take over the display controller hardware without cutting clocks, blanking or reseting it. Handing off the clock reference count helps achieve this.

[0] lkml.kernel.org/g/1455225554-13267-1-git-send-email-mturquette at baylibre.com

Regards,
Mike

Quoted 61 lines
Quoted 33 lines

Up to now, the workaround for this has been to use the Linux kernel command line parameter 'clk_ignore_unused'. See Xen bug

http://bugs.xenproject.org/xen/bug/45

too.

To fix this, we will add the "unused" clocks in Xen to the hypervisor node. The OS has to consume and enable the clocks from the hypervisor node, then.

Therefore, check if there is a "clocks" entry in the hypervisor node and if so consume and enable the given clocks. This prevents the clocks from being disabled by the OS.

---
Changes in v3: Use the xen.txt description proposed by Michael. Thanks!

Changes in v2: Drop the Linux implementation details like clk_disable_unused
in xen.txt.

  Documentation/devicetree/bindings/arm/xen.txt | 13 ++++++++
  arch/arm/xen/enlighten.c                      | 47 +++++++++++++++++++++++++++
  2 files changed, 60 insertions(+)
Documentation/devicetree/bindings/arm/xen.txt +0 -0
index c9b9321..00f2165 100644

Documentation/devicetree/bindings/arm/xen.txt the following properties: · line 23

Quoted 7 lines
Documentation/devicetree/bindings/arm/xen.txt +4 -0
@@ -17,6 +17,19 @@ the following properties:
    A GIC node is also required.
    This property is unnecessary when booting Dom0 using ACPI.
 
+Optional properties:
+
+clocks: one or more clocks to be enabled
+  Xen hypervisor drivers might replace native OS drivers. The result is

"native OS" has no meaning on Xen. This seems to be a cumbersome way to say that the device will be used by the hypervisor and hidden to DOM0 (aka hardware domain).

Documentation/devicetree/bindings/arm/xen.txt the following properties: · line 34

Quoted 11 lines
Documentation/devicetree/bindings/arm/xen.txt +9 -0
+  that some important clocks that are enabled by the OS in the non-Xen
+  case are not properly enabled in the presence of Xen. The clocks
+  property enumerates the clocks that must be enabled by the Xen clock
+  consumer.
+  An example is a serial driver enabled by the hypervisor. Xen must
+  consume and enable these clocks in the OS to ensure behavior continues
+  after firmware configures the UART hardware and corresponding clock
+  harder.
+
  To support UEFI on Xen ARM virtual platforms, Xen populates the FDT "uefi" node
  under /hypervisor with following parameters:

Regards,

Signature · 1 line
Julien Grall
#9 lore raw

PATCH v3 1/1 xen/arm: enable clocks used by the hypervisor

Hi Mike,

Quoted 33 lines · Michael Turquette

Quoting Julien Grall (2016-07-08 02:34:43)

Quoted 24 lines

Hi Dirk,

Quoted 7 lines · Dirk Behme

Xen hypervisor drivers might replace native OS drivers. The result is that some important clocks that are enabled by the OS in the non-Xen case are not properly enabled in the presence of Xen. The clocks property enumerates the clocks that must be enabled by the Xen clock consumer.

An example is a serial driver enabled by the hypervisor. Xen must

I would say "An example is the UART used by the hypervisor."

Quoted 3 lines

consume and enable these clocks in the OS to ensure behavior continues after firmware configures the UART hardware and corresponding clock harder.

What do you mean by "harder"?

Also, relying on DOM0 to enable the clock looks very wrong to me and you give an example which prove that. The UART will be used before hand by Xen, however it will not be possible to use it if you expect DOM0 to enable the clock (or even modify the clock frequency).

Quoted 7 lines

The clock should be enabled either by the firmware or Xen. But not DOM0. DOM0 should not touch this clock at all.

Furthermore, this property could be used for clock associated to device that will be passthrough-ed to a guest. In this case, the clock would be enabled even if the device is not in use which will result more power consumption.

Quoted 7 lines

Is there a need to pass clock references through to guests? If so the unmerged CLK_ENABLE_HAND_OFF[0] feature might be useful to you? If this flag is set on a given clk, it will be enabled at the time it is registered by the clk provider driver, and it's enable_count reference counter will be "handed off" to the first consumer that calls clk_get() and clk_prepare_enable() on it. This means the clock CAN be gated by it's proper driver, but it will be enabled at boot time as well.

Some driver requires to have the clock in hand to be able to configure the clock (such as setting the rate). So we would have to find a way to let the guest using the clock either by assigning the clock or some PV clock driver.

However, platform device passthrough (i.e non-pci device) cannot be done generically. The user has to provide a lots of information manually (such as MMIO, IRQ, device tree node...). So I am not sure if we want to have a generic solution here.

I though it would be worth to mention it because we may (or not) use this clock to tell DOM0 (don't touch it).

Quoted 5 lines

This is useful for use cases like splash screens where the bootloader configures the display and plays some animation, and we want the linux kernel to take over the display controller hardware without cutting clocks, blanking or reseting it. Handing off the clock reference count helps achieve this.

From my understanding, any device used by Xen would be in a similar
situation, although there will be no driver in Linux. The current patch (as well as the v4) is calling clk_prepare_enable for each clock used by Xen. Could enabling the clock create unexpected behavior such as the UART loosing/dropping characters?

Regards,

Signature · 1 line
Julien Grall
#10 lore raw

PATCH v3 1/1 xen/arm: enable clocks used by the hypervisor

Quoting Julien Grall (2016-07-12 02:21:12)

Quoted 63 lines

Hi Mike,

Quoted 33 lines · Michael Turquette

Quoting Julien Grall (2016-07-08 02:34:43)

Quoted 24 lines

Hi Dirk,

Quoted 7 lines · Dirk Behme

Xen hypervisor drivers might replace native OS drivers. The result is that some important clocks that are enabled by the OS in the non-Xen case are not properly enabled in the presence of Xen. The clocks property enumerates the clocks that must be enabled by the Xen clock consumer.

An example is a serial driver enabled by the hypervisor. Xen must

I would say "An example is the UART used by the hypervisor."

Quoted 3 lines

consume and enable these clocks in the OS to ensure behavior continues after firmware configures the UART hardware and corresponding clock harder.

What do you mean by "harder"?

Also, relying on DOM0 to enable the clock looks very wrong to me and you give an example which prove that. The UART will be used before hand by Xen, however it will not be possible to use it if you expect DOM0 to enable the clock (or even modify the clock frequency).

Quoted 7 lines

The clock should be enabled either by the firmware or Xen. But not DOM0. DOM0 should not touch this clock at all.

Furthermore, this property could be used for clock associated to device that will be passthrough-ed to a guest. In this case, the clock would be enabled even if the device is not in use which will result more power consumption.

Quoted 7 lines

Is there a need to pass clock references through to guests? If so the unmerged CLK_ENABLE_HAND_OFF[0] feature might be useful to you? If this flag is set on a given clk, it will be enabled at the time it is registered by the clk provider driver, and it's enable_count reference counter will be "handed off" to the first consumer that calls clk_get() and clk_prepare_enable() on it. This means the clock CAN be gated by it's proper driver, but it will be enabled at boot time as well.

Some driver requires to have the clock in hand to be able to configure the clock (such as setting the rate). So we would have to find a way to let the guest using the clock either by assigning the clock or some PV clock driver.

However, platform device passthrough (i.e non-pci device) cannot be done generically. The user has to provide a lots of information manually (such as MMIO, IRQ, device tree node...). So I am not sure if we want to have a generic solution here.

I though it would be worth to mention it because we may (or not) use this clock to tell DOM0 (don't touch it).

Quoted 5 lines

This is useful for use cases like splash screens where the bootloader configures the display and plays some animation, and we want the linux kernel to take over the display controller hardware without cutting clocks, blanking or reseting it. Handing off the clock reference count helps achieve this.

Quoted 5 lines

From my understanding, any device used by Xen would be in a similar
situation, although there will be no driver in Linux. The current patch (as well as the v4) is calling clk_prepare_enable for each clock used by Xen. Could enabling the clock create unexpected behavior such as the UART loosing/dropping characters?

In general, no, it will not cause any bad side effect.

Regards,
Mike

Quoted 5 lines

Regards,

Signature · 1 line
Julien Grall
#11 lore raw
In reply to Julien Grall

Quoting Julien Grall (2016-07-12 02:21:12)

Quoted 63 lines

Hi Mike,

Quoted 33 lines · Michael Turquette

Quoting Julien Grall (2016-07-08 02:34:43)

Quoted 24 lines

Hi Dirk,

Quoted 7 lines · Dirk Behme

Xen hypervisor drivers might replace native OS drivers. The result is that some important clocks that are enabled by the OS in the non-Xen case are not properly enabled in the presence of Xen. The clocks property enumerates the clocks that must be enabled by the Xen clock consumer.

An example is a serial driver enabled by the hypervisor. Xen must

I would say "An example is the UART used by the hypervisor."

Quoted 3 lines

consume and enable these clocks in the OS to ensure behavior continues after firmware configures the UART hardware and corresponding clock harder.

What do you mean by "harder"?

Also, relying on DOM0 to enable the clock looks very wrong to me and you give an example which prove that. The UART will be used before hand by Xen, however it will not be possible to use it if you expect DOM0 to enable the clock (or even modify the clock frequency).

Quoted 7 lines

The clock should be enabled either by the firmware or Xen. But not DOM0. DOM0 should not touch this clock at all.

Furthermore, this property could be used for clock associated to device that will be passthrough-ed to a guest. In this case, the clock would be enabled even if the device is not in use which will result more power consumption.

Quoted 7 lines

Is there a need to pass clock references through to guests? If so the unmerged CLK_ENABLE_HAND_OFF[0] feature might be useful to you? If this flag is set on a given clk, it will be enabled at the time it is registered by the clk provider driver, and it's enable_count reference counter will be "handed off" to the first consumer that calls clk_get() and clk_prepare_enable() on it. This means the clock CAN be gated by it's proper driver, but it will be enabled at boot time as well.

Some driver requires to have the clock in hand to be able to configure the clock (such as setting the rate). So we would have to find a way to let the guest using the clock either by assigning the clock or some PV clock driver.

However, platform device passthrough (i.e non-pci device) cannot be done generically. The user has to provide a lots of information manually (such as MMIO, IRQ, device tree node...). So I am not sure if we want to have a generic solution here.

I though it would be worth to mention it because we may (or not) use this clock to tell DOM0 (don't touch it).

Quoted 5 lines

This is useful for use cases like splash screens where the bootloader configures the display and plays some animation, and we want the linux kernel to take over the display controller hardware without cutting clocks, blanking or reseting it. Handing off the clock reference count helps achieve this.

Quoted 5 lines

From my understanding, any device used by Xen would be in a similar
situation, although there will be no driver in Linux. The current patch (as well as the v4) is calling clk_prepare_enable for each clock used by Xen. Could enabling the clock create unexpected behavior such as the UART loosing/dropping characters?

In general, no, it will not cause any bad side effect.

Regards,
Mike

Quoted 5 lines

Regards,

Signature · 1 line
Julien Grall

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

#12 lore raw
In reply to Michael Turquette

Hi Mike,

Quoted 33 lines · Michael Turquette

Quoting Julien Grall (2016-07-08 02:34:43)

Quoted 24 lines

Hi Dirk,

Quoted 7 lines · Dirk Behme

Xen hypervisor drivers might replace native OS drivers. The result is that some important clocks that are enabled by the OS in the non-Xen case are not properly enabled in the presence of Xen. The clocks property enumerates the clocks that must be enabled by the Xen clock consumer.

An example is a serial driver enabled by the hypervisor. Xen must

I would say "An example is the UART used by the hypervisor."

Quoted 3 lines

consume and enable these clocks in the OS to ensure behavior continues after firmware configures the UART hardware and corresponding clock harder.

What do you mean by "harder"?

Also, relying on DOM0 to enable the clock looks very wrong to me and you give an example which prove that. The UART will be used before hand by Xen, however it will not be possible to use it if you expect DOM0 to enable the clock (or even modify the clock frequency).

Quoted 7 lines

The clock should be enabled either by the firmware or Xen. But not DOM0. DOM0 should not touch this clock at all.

Furthermore, this property could be used for clock associated to device that will be passthrough-ed to a guest. In this case, the clock would be enabled even if the device is not in use which will result more power consumption.

Quoted 7 lines

Is there a need to pass clock references through to guests? If so the unmerged CLK_ENABLE_HAND_OFF[0] feature might be useful to you? If this flag is set on a given clk, it will be enabled at the time it is registered by the clk provider driver, and it's enable_count reference counter will be "handed off" to the first consumer that calls clk_get() and clk_prepare_enable() on it. This means the clock CAN be gated by it's proper driver, but it will be enabled at boot time as well.

Some driver requires to have the clock in hand to be able to configure the clock (such as setting the rate). So we would have to find a way to let the guest using the clock either by assigning the clock or some PV clock driver.

However, platform device passthrough (i.e non-pci device) cannot be done generically. The user has to provide a lots of information manually (such as MMIO, IRQ, device tree node...). So I am not sure if we want to have a generic solution here.

I though it would be worth to mention it because we may (or not) use this clock to tell DOM0 (don't touch it).

Quoted 5 lines

This is useful for use cases like splash screens where the bootloader configures the display and plays some animation, and we want the linux kernel to take over the display controller hardware without cutting clocks, blanking or reseting it. Handing off the clock reference count helps achieve this.

From my understanding, any device used by Xen would be in a similar situation, although there will be no driver in Linux. The current patch (as well as the v4) is calling clk_prepare_enable for each clock used by Xen. Could enabling the clock create unexpected behavior such as the UART loosing/dropping characters?

Regards,

Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#13 lore raw
In reply to Julien Grall

Quoting Julien Grall (2016-07-08 02:34:43)

Quoted 24 lines

Hi Dirk,

Quoted 7 lines · Dirk Behme

Xen hypervisor drivers might replace native OS drivers. The result is that some important clocks that are enabled by the OS in the non-Xen case are not properly enabled in the presence of Xen. The clocks property enumerates the clocks that must be enabled by the Xen clock consumer.

An example is a serial driver enabled by the hypervisor. Xen must

I would say "An example is the UART used by the hypervisor."

Quoted 3 lines

consume and enable these clocks in the OS to ensure behavior continues after firmware configures the UART hardware and corresponding clock harder.

What do you mean by "harder"?

Also, relying on DOM0 to enable the clock looks very wrong to me and you give an example which prove that. The UART will be used before hand by Xen, however it will not be possible to use it if you expect DOM0 to enable the clock (or even modify the clock frequency).

Quoted 7 lines

The clock should be enabled either by the firmware or Xen. But not DOM0. DOM0 should not touch this clock at all.

Furthermore, this property could be used for clock associated to device that will be passthrough-ed to a guest. In this case, the clock would be enabled even if the device is not in use which will result more power consumption.

Is there a need to pass clock references through to guests? If so the unmerged CLK_ENABLE_HAND_OFF[0] feature might be useful to you? If this flag is set on a given clk, it will be enabled at the time it is registered by the clk provider driver, and it's enable_count reference counter will be "handed off" to the first consumer that calls clk_get() and clk_prepare_enable() on it. This means the clock CAN be gated by it's proper driver, but it will be enabled at boot time as well.

This is useful for use cases like splash screens where the bootloader configures the display and plays some animation, and we want the linux kernel to take over the display controller hardware without cutting clocks, blanking or reseting it. Handing off the clock reference count helps achieve this.

[0] lkml.kernel.org/g/[email protected]

Regards,
Mike

Quoted 57 lines
Quoted 33 lines

Up to now, the workaround for this has been to use the Linux kernel command line parameter 'clk_ignore_unused'. See Xen bug

http://bugs.xenproject.org/xen/bug/45

too.

To fix this, we will add the "unused" clocks in Xen to the hypervisor node. The OS has to consume and enable the clocks from the hypervisor node, then.

Therefore, check if there is a "clocks" entry in the hypervisor node and if so consume and enable the given clocks. This prevents the clocks from being disabled by the OS.

---
Changes in v3: Use the xen.txt description proposed by Michael. Thanks!

Changes in v2: Drop the Linux implementation details like clk_disable_unused
in xen.txt.

  Documentation/devicetree/bindings/arm/xen.txt | 13 ++++++++
  arch/arm/xen/enlighten.c                      | 47 +++++++++++++++++++++++++++
  2 files changed, 60 insertions(+)
Documentation/devicetree/bindings/arm/xen.txt +0 -0
index c9b9321..00f2165 100644

Documentation/devicetree/bindings/arm/xen.txt the following properties: · line 23

Quoted 7 lines
Documentation/devicetree/bindings/arm/xen.txt +4 -0
@@ -17,6 +17,19 @@ the following properties:
    A GIC node is also required.
    This property is unnecessary when booting Dom0 using ACPI.
 
+Optional properties:
+
+clocks: one or more clocks to be enabled
+  Xen hypervisor drivers might replace native OS drivers. The result is

"native OS" has no meaning on Xen. This seems to be a cumbersome way to say that the device will be used by the hypervisor and hidden to DOM0 (aka hardware domain).

Documentation/devicetree/bindings/arm/xen.txt the following properties: · line 34

Quoted 11 lines
Documentation/devicetree/bindings/arm/xen.txt +9 -0
+  that some important clocks that are enabled by the OS in the non-Xen
+  case are not properly enabled in the presence of Xen. The clocks
+  property enumerates the clocks that must be enabled by the Xen clock
+  consumer.
+  An example is a serial driver enabled by the hypervisor. Xen must
+  consume and enable these clocks in the OS to ensure behavior continues
+  after firmware configures the UART hardware and corresponding clock
+  harder.
+
  To support UEFI on Xen ARM virtual platforms, Xen populates the FDT "uefi" node
  under /hypervisor with following parameters:
Quoted 4 lines

Regards,

Signature · 1 line
Julien Grall

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

#14 lore raw
In reply to Dirk Behme

Hi Dirk,

Quoted 7 lines · Dirk Behme

Xen hypervisor drivers might replace native OS drivers. The result is that some important clocks that are enabled by the OS in the non-Xen case are not properly enabled in the presence of Xen. The clocks property enumerates the clocks that must be enabled by the Xen clock consumer.

An example is a serial driver enabled by the hypervisor. Xen must

I would say "An example is the UART used by the hypervisor."

Quoted 3 lines

consume and enable these clocks in the OS to ensure behavior continues after firmware configures the UART hardware and corresponding clock harder.

What do you mean by "harder"?

Also, relying on DOM0 to enable the clock looks very wrong to me and you give an example which prove that. The UART will be used before hand by Xen, however it will not be possible to use it if you expect DOM0 to enable the clock (or even modify the clock frequency).

The clock should be enabled either by the firmware or Xen. But not DOM0. DOM0 should not touch this clock at all.

Furthermore, this property could be used for clock associated to device that will be passthrough-ed to a guest. In this case, the clock would be enabled even if the device is not in use which will result more power consumption.

Quoted 32 lines

Up to now, the workaround for this has been to use the Linux kernel command line parameter 'clk_ignore_unused'. See Xen bug

http://bugs.xenproject.org/xen/bug/45

too.

To fix this, we will add the "unused" clocks in Xen to the hypervisor node. The OS has to consume and enable the clocks from the hypervisor node, then.

Therefore, check if there is a "clocks" entry in the hypervisor node and if so consume and enable the given clocks. This prevents the clocks from being disabled by the OS.

---
Changes in v3: Use the xen.txt description proposed by Michael. Thanks!

Changes in v2: Drop the Linux implementation details like clk_disable_unused
in xen.txt.

  Documentation/devicetree/bindings/arm/xen.txt | 13 ++++++++
  arch/arm/xen/enlighten.c                      | 47 +++++++++++++++++++++++++++
  2 files changed, 60 insertions(+)
Documentation/devicetree/bindings/arm/xen.txt +0 -0
index c9b9321..00f2165 100644

Documentation/devicetree/bindings/arm/xen.txt the following properties: · line 23

Quoted 7 lines
Documentation/devicetree/bindings/arm/xen.txt +4 -0
@@ -17,6 +17,19 @@ the following properties:
    A GIC node is also required.
    This property is unnecessary when booting Dom0 using ACPI.
 
+Optional properties:
+
+clocks: one or more clocks to be enabled
+  Xen hypervisor drivers might replace native OS drivers. The result is

"native OS" has no meaning on Xen. This seems to be a cumbersome way to say that the device will be used by the hypervisor and hidden to DOM0 (aka hardware domain).

Documentation/devicetree/bindings/arm/xen.txt the following properties: · line 34

Quoted 11 lines
Documentation/devicetree/bindings/arm/xen.txt +9 -0
+  that some important clocks that are enabled by the OS in the non-Xen
+  case are not properly enabled in the presence of Xen. The clocks
+  property enumerates the clocks that must be enabled by the Xen clock
+  consumer.
+  An example is a serial driver enabled by the hypervisor. Xen must
+  consume and enable these clocks in the OS to ensure behavior continues
+  after firmware configures the UART hardware and corresponding clock
+  harder.
+
  To support UEFI on Xen ARM virtual platforms, Xen populates the FDT "uefi" node
  under /hypervisor with following parameters:

Regards,

Signature · 6 lines
Julien Grall

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