Skip to contentSkip to conversation

xen/arm: register clocks used by the hypervisor

PATCH Superseded Dirk Behme 3 participants 9 messages Jul 5, 2016 – Jul 6, 2016

Subsystems (4)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Dirk Behme

author
#0 lore raw

PATCH v2 1/1 xen/arm: register clocks used by the hypervisor

Some clocks might be used by the Xen hypervisor and not by the Linux kernel. If these are not registered by the Linux kernel, they might be disabled by clk_disable_unused() as the kernel doesn't know that they are used. The clock of the serial console handled by Xen is one example for this. It might be disabled by clk_disable_unused() which stops the whole serial output, even from Xen, then.

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 Linux kernel has to register the clocks from the hypervisor node, then.

Therefore, check if there is a "clocks" entry in the hypervisor node and if so register the given clocks to the Linux kernel clock framework and with this mark them as used. This prevents the clocks from being disabled.

---
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..21fd469 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 registered.
+  Xen hypervisor drivers might replace native drivers, resulting in
+  clocks not registered by these native drivers. To avoid that these
+  unregistered clocks are disabled by the Linux kernel initialization
+  register them in the hypervisor node.
+  An example for this are the clocks of a serial driver already enabled
+  by the firmware. If the clocks used by the serial hardware interface
+  are not registered by the serial driver itself the serial output
+  might stop once the Linux kernel initialization disables the 'unused'
+  clocks.
+
 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 v2 1/1 xen/arm: register clocks used by the hypervisor

Hi,

Quoted 23 lines · Dirk Behme

Some clocks might be used by the Xen hypervisor and not by the Linux kernel. If these are not registered by the Linux kernel, they might be disabled by clk_disable_unused() as the kernel doesn't know that they are used. The clock of the serial console handled by Xen is one example for this. It might be disabled by clk_disable_unused() which stops the whole serial output, even from Xen, then.

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 Linux kernel has to register the clocks from the hypervisor node, then.

Therefore, check if there is a "clocks" entry in the hypervisor node and if so register the given clocks to the Linux kernel clock framework and with this mark them as used. This prevents the clocks from being disabled.

Quoted 4 lines

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

Thanks for doing this.

Quoted 14 lines
 Documentation/devicetree/bindings/arm/xen.txt | 13 ++++++++
 arch/arm/xen/enlighten.c                      | 47 +++++++++++++++++++++++++++
 2 files changed, 60 insertions(+)
Documentation/devicetree/bindings/arm/xen.txt +2 -0
index c9b9321..21fd469 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:
+

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

Quoted 10 lines
Documentation/devicetree/bindings/arm/xen.txt +10 -0
+- clocks: one or more clocks to be registered.
+  Xen hypervisor drivers might replace native drivers, resulting in
+  clocks not registered by these native drivers. To avoid that these
+  unregistered clocks are disabled by the Linux kernel initialization
+  register them in the hypervisor node.
+  An example for this are the clocks of a serial driver already enabled
+  by the firmware. If the clocks used by the serial hardware interface
+  are not registered by the serial driver itself the serial output
+  might stop once the Linux kernel initialization disables the 'unused'
+  clocks.

The above describes the set of problems, but doesn't set out the actual contract. It also covers a number of Linux implementation details in abstract.

As I commented previously [1], the binding should describe the set of guarantees that you rewquire (e.g. that the clocks must be left as-is, not gated, and their rates left unchanged).

Please describe the specific set of guarantees that you require.

Thanks,
Mark.

[1] http://lists.infradead.org/pipermail/linux-arm-kernel/2016-June/440434.html

author
#2 lore raw

PATCH v2 1/1 xen/arm: register clocks used by the hypervisor

Hi Mark,

Quoted 45 lines · Mark Rutland

Hi,

Quoted 23 lines · Dirk Behme

Some clocks might be used by the Xen hypervisor and not by the Linux kernel. If these are not registered by the Linux kernel, they might be disabled by clk_disable_unused() as the kernel doesn't know that they are used. The clock of the serial console handled by Xen is one example for this. It might be disabled by clk_disable_unused() which stops the whole serial output, even from Xen, then.

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 Linux kernel has to register the clocks from the hypervisor node, then.

Therefore, check if there is a "clocks" entry in the hypervisor node and if so register the given clocks to the Linux kernel clock framework and with this mark them as used. This prevents the clocks from being disabled.

Quoted 4 lines

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

Thanks for doing this.

Quoted 12 lines
 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..21fd469 100644
@@ -17,6 +17,19 @@ the following properties:
   A GIC node is also required.
   This property is unnecessary when booting Dom0 using ACPI.
 
Quoted 16 lines

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

Quoted 12 lines
Documentation/devicetree/bindings/arm/xen.txt +12 -0
+Optional properties:
+
+- clocks: one or more clocks to be registered.
+  Xen hypervisor drivers might replace native drivers, resulting in
+  clocks not registered by these native drivers. To avoid that these
+  unregistered clocks are disabled by the Linux kernel initialization
+  register them in the hypervisor node.
+  An example for this are the clocks of a serial driver already enabled
+  by the firmware. If the clocks used by the serial hardware interface
+  are not registered by the serial driver itself the serial output
+  might stop once the Linux kernel initialization disables the 'unused'
+  clocks.

The above describes the set of problems, but doesn't set out the actual contract. It also covers a number of Linux implementation details in abstract.

Could you kindly be a little more specific which 'implementation details' you don't like?

E.g. to my understanding, the 'implementation detail' that Linux disables unregistered clocks is needed for the description.

If you have a different wording in mind, could you kindly share that?

Quoted 5 lines

As I commented previously [1], the binding should describe the set of guarantees that you rewquire (e.g. that the clocks must be left as-is, not gated, and their rates left unchanged).

Please describe the specific set of guarantees that you require.

To my understanding this is done, already: "avoid that these ... clocks are disabled"

Best regards

Dirk

#3 lore raw

PATCH v2 1/1 xen/arm: register clocks used by the hypervisor

Hi,

Quoted 13 lines · Dirk Behme
Quoted 12 lines · Mark Rutland
Quoted 10 lines · Dirk Behme

+- clocks: one or more clocks to be registered.

Documentation/devicetree/bindings/arm/xen.txt +9 -0
+  Xen hypervisor drivers might replace native drivers, resulting in
+  clocks not registered by these native drivers. To avoid that these
+  unregistered clocks are disabled by the Linux kernel initialization
+  register them in the hypervisor node.
+  An example for this are the clocks of a serial driver already enabled
+  by the firmware. If the clocks used by the serial hardware interface
+  are not registered by the serial driver itself the serial output
+  might stop once the Linux kernel initialization disables the 'unused'
+  clocks.
Quoted 6 lines
Quoted 3 lines

The above describes the set of problems, but doesn't set out the actual contract. It also covers a number of Linux implementation details in abstract.

Could you kindly be a little more specific which 'implementation details' you don't like?

The fact that we disable some clocks at init time is a driver model thing that depends on various factors (e.g. cmdline options), and it's something that could be moved around. We only mention disabling, and not rate change (which could happen, even if it doesn't today).

I don't think that we need to describe the Linux behaviour at all.

Quoted 4 lines

E.g. to my understanding, the 'implementation detail' that Linux disables unregistered clocks is needed for the description.

If you have a different wording in mind, could you kindly share that?

Something like:

- clocks: a list of phandle + clock-specifier pairs
Clocks described by this property are reserved for use by Xen, and the OS must not alter their state any way, such as disabling or gating a clock, or modifying its rate. Ensuring this may impose constraints on parent clocks or other resources used by the clock tree.

Note: this property is used to proxy clocks for devices Xen has taken ownership of, such as UARTs, for which the associated clock controller(s) remain under the control of Dom0.

Quoted 8 lines
Quoted 5 lines

As I commented previously [1], the binding should describe the set of guarantees that you rewquire (e.g. that the clocks must be left as-is, not gated, and their rates left unchanged).

Please describe the specific set of guarantees that you require.

To my understanding this is done, already: "avoid that these ... clocks are disabled"

My point of contention here is that while this might tell a dts author what to place in this property, it doesn't specify what the OS should do.

Thanks,
Mark.

#4 lore raw

PATCH v2 1/1 xen/arm: register clocks used by the hypervisor

Quoting Mark Rutland (2016-07-05 04:07:37)

Quoted 43 lines

Hi,

Quoted 13 lines · Dirk Behme
Quoted 12 lines · Mark Rutland
Quoted 10 lines · Dirk Behme

+- clocks: one or more clocks to be registered.

Documentation/devicetree/bindings/arm/xen.txt +9 -0
+  Xen hypervisor drivers might replace native drivers, resulting in
+  clocks not registered by these native drivers. To avoid that these
+  unregistered clocks are disabled by the Linux kernel initialization
+  register them in the hypervisor node.
+  An example for this are the clocks of a serial driver already enabled
+  by the firmware. If the clocks used by the serial hardware interface
+  are not registered by the serial driver itself the serial output
+  might stop once the Linux kernel initialization disables the 'unused'
+  clocks.
Quoted 6 lines
Quoted 3 lines

The above describes the set of problems, but doesn't set out the actual contract. It also covers a number of Linux implementation details in abstract.

Could you kindly be a little more specific which 'implementation details' you don't like?

The fact that we disable some clocks at init time is a driver model thing that depends on various factors (e.g. cmdline options), and it's something that could be moved around. We only mention disabling, and not rate change (which could happen, even if it doesn't today).

I don't think that we need to describe the Linux behaviour at all.

Quoted 4 lines

E.g. to my understanding, the 'implementation detail' that Linux disables unregistered clocks is needed for the description.

If you have a different wording in mind, could you kindly share that?

Something like:

- clocks: a list of phandle + clock-specifier pairs
Clocks described by this property are reserved for use by Xen, and the OS must not alter their state any way, such as disabling or gating a clock, or modifying its rate. Ensuring this may impose constraints on parent clocks or other resources used by the clock tree.

Quoted 3 lines

Note: this property is used to proxy clocks for devices Xen has taken ownership of, such as UARTs, for which the associated clock controller(s) remain under the control of Dom0.

Fully agree that we should forget the clk_disable_unused stuff entirely. Mark's copy above is good, and just for the fun of it I have provided an alternative version. Feel free to pick and choose what you want:

- 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.

Regards,
Mike

Quoted 16 lines
Quoted 9 lines
Quoted 6 lines

As I commented previously [1], the binding should describe the set of guarantees that you rewquire (e.g. that the clocks must be left as-is, not gated, and their rates left unchanged).

Please describe the specific set of guarantees that you require.

To my understanding this is done, already: "avoid that these ... clocks are disabled"

My point of contention here is that while this might tell a dts author what to place in this property, it doesn't specify what the OS should do.

Thanks,
Mark.

#5 lore raw
In reply to Mark Rutland

Quoting Mark Rutland (2016-07-05 04:07:37)

Quoted 43 lines

Hi,

Quoted 13 lines · Dirk Behme
Quoted 12 lines · Mark Rutland
Quoted 10 lines · Dirk Behme

+- clocks: one or more clocks to be registered.

Documentation/devicetree/bindings/arm/xen.txt +9 -0
+  Xen hypervisor drivers might replace native drivers, resulting in
+  clocks not registered by these native drivers. To avoid that these
+  unregistered clocks are disabled by the Linux kernel initialization
+  register them in the hypervisor node.
+  An example for this are the clocks of a serial driver already enabled
+  by the firmware. If the clocks used by the serial hardware interface
+  are not registered by the serial driver itself the serial output
+  might stop once the Linux kernel initialization disables the 'unused'
+  clocks.
Quoted 6 lines
Quoted 3 lines

The above describes the set of problems, but doesn't set out the actual contract. It also covers a number of Linux implementation details in abstract.

Could you kindly be a little more specific which 'implementation details' you don't like?

The fact that we disable some clocks at init time is a driver model thing that depends on various factors (e.g. cmdline options), and it's something that could be moved around. We only mention disabling, and not rate change (which could happen, even if it doesn't today).

I don't think that we need to describe the Linux behaviour at all.

Quoted 4 lines

E.g. to my understanding, the 'implementation detail' that Linux disables unregistered clocks is needed for the description.

If you have a different wording in mind, could you kindly share that?

Something like:

- clocks: a list of phandle + clock-specifier pairs
Clocks described by this property are reserved for use by Xen, and the OS must not alter their state any way, such as disabling or gating a clock, or modifying its rate. Ensuring this may impose constraints on parent clocks or other resources used by the clock tree.

Quoted 3 lines

Note: this property is used to proxy clocks for devices Xen has taken ownership of, such as UARTs, for which the associated clock controller(s) remain under the control of Dom0.

Fully agree that we should forget the clk_disable_unused stuff entirely. Mark's copy above is good, and just for the fun of it I have provided an alternative version. Feel free to pick and choose what you want:

- 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.

Regards,
Mike

Quoted 10 lines
Quoted 9 lines
Quoted 6 lines

As I commented previously [1], the binding should describe the set of guarantees that you rewquire (e.g. that the clocks must be left as-is, not gated, and their rates left unchanged).

Please describe the specific set of guarantees that you require.

To my understanding this is done, already: "avoid that these ... clocks are disabled"

Quoted 6 lines

My point of contention here is that while this might tell a dts author what to place in this property, it doesn't specify what the OS should do.

Thanks,
Mark.

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

#6 lore raw
In reply to Dirk Behme

Hi,

Quoted 13 lines · Dirk Behme
Quoted 12 lines · Mark Rutland
Quoted 10 lines · Dirk Behme

+- clocks: one or more clocks to be registered.

Documentation/devicetree/bindings/arm/xen.txt +9 -0
+  Xen hypervisor drivers might replace native drivers, resulting in
+  clocks not registered by these native drivers. To avoid that these
+  unregistered clocks are disabled by the Linux kernel initialization
+  register them in the hypervisor node.
+  An example for this are the clocks of a serial driver already enabled
+  by the firmware. If the clocks used by the serial hardware interface
+  are not registered by the serial driver itself the serial output
+  might stop once the Linux kernel initialization disables the 'unused'
+  clocks.
Quoted 6 lines
Quoted 3 lines

The above describes the set of problems, but doesn't set out the actual contract. It also covers a number of Linux implementation details in abstract.

Could you kindly be a little more specific which 'implementation details' you don't like?

The fact that we disable some clocks at init time is a driver model thing that depends on various factors (e.g. cmdline options), and it's something that could be moved around. We only mention disabling, and not rate change (which could happen, even if it doesn't today).

I don't think that we need to describe the Linux behaviour at all.

Quoted 4 lines

E.g. to my understanding, the 'implementation detail' that Linux disables unregistered clocks is needed for the description.

If you have a different wording in mind, could you kindly share that?

Something like:

- clocks: a list of phandle + clock-specifier pairs
Clocks described by this property are reserved for use by Xen, and the OS must not alter their state any way, such as disabling or gating a clock, or modifying its rate. Ensuring this may impose constraints on parent clocks or other resources used by the clock tree.

Note: this property is used to proxy clocks for devices Xen has taken ownership of, such as UARTs, for which the associated clock controller(s) remain under the control of Dom0.

Quoted 8 lines
Quoted 5 lines

As I commented previously [1], the binding should describe the set of guarantees that you rewquire (e.g. that the clocks must be left as-is, not gated, and their rates left unchanged).

Please describe the specific set of guarantees that you require.

To my understanding this is done, already: "avoid that these ... clocks are disabled"

My point of contention here is that while this might tell a dts author what to place in this property, it doesn't specify what the OS should do.

Thanks,
Mark.

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

author
#7 lore raw
In reply to Mark Rutland

Hi Mark,

Quoted 45 lines · Mark Rutland

Hi,

Quoted 23 lines · Dirk Behme

Some clocks might be used by the Xen hypervisor and not by the Linux kernel. If these are not registered by the Linux kernel, they might be disabled by clk_disable_unused() as the kernel doesn't know that they are used. The clock of the serial console handled by Xen is one example for this. It might be disabled by clk_disable_unused() which stops the whole serial output, even from Xen, then.

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 Linux kernel has to register the clocks from the hypervisor node, then.

Therefore, check if there is a "clocks" entry in the hypervisor node and if so register the given clocks to the Linux kernel clock framework and with this mark them as used. This prevents the clocks from being disabled.

Quoted 4 lines

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

Thanks for doing this.

Quoted 12 lines
 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..21fd469 100644
@@ -17,6 +17,19 @@ the following properties:
   A GIC node is also required.
   This property is unnecessary when booting Dom0 using ACPI.
 
Quoted 16 lines

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

Quoted 12 lines
Documentation/devicetree/bindings/arm/xen.txt +12 -0
+Optional properties:
+
+- clocks: one or more clocks to be registered.
+  Xen hypervisor drivers might replace native drivers, resulting in
+  clocks not registered by these native drivers. To avoid that these
+  unregistered clocks are disabled by the Linux kernel initialization
+  register them in the hypervisor node.
+  An example for this are the clocks of a serial driver already enabled
+  by the firmware. If the clocks used by the serial hardware interface
+  are not registered by the serial driver itself the serial output
+  might stop once the Linux kernel initialization disables the 'unused'
+  clocks.

The above describes the set of problems, but doesn't set out the actual contract. It also covers a number of Linux implementation details in abstract.

Could you kindly be a little more specific which 'implementation details' you don't like?

E.g. to my understanding, the 'implementation detail' that Linux disables unregistered clocks is needed for the description.

If you have a different wording in mind, could you kindly share that?

Quoted 5 lines

As I commented previously [1], the binding should describe the set of guarantees that you rewquire (e.g. that the clocks must be left as-is, not gated, and their rates left unchanged).

Please describe the specific set of guarantees that you require.

To my understanding this is done, already: "avoid that these ... clocks are disabled"

Best regards

Dirk

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

#8 lore raw
In reply to Dirk Behme

Hi,

Quoted 23 lines · Dirk Behme

Some clocks might be used by the Xen hypervisor and not by the Linux kernel. If these are not registered by the Linux kernel, they might be disabled by clk_disable_unused() as the kernel doesn't know that they are used. The clock of the serial console handled by Xen is one example for this. It might be disabled by clk_disable_unused() which stops the whole serial output, even from Xen, then.

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 Linux kernel has to register the clocks from the hypervisor node, then.

Therefore, check if there is a "clocks" entry in the hypervisor node and if so register the given clocks to the Linux kernel clock framework and with this mark them as used. This prevents the clocks from being disabled.

Quoted 4 lines

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

Thanks for doing this.

Quoted 14 lines
 Documentation/devicetree/bindings/arm/xen.txt | 13 ++++++++
 arch/arm/xen/enlighten.c                      | 47 +++++++++++++++++++++++++++
 2 files changed, 60 insertions(+)
Documentation/devicetree/bindings/arm/xen.txt +2 -0
index c9b9321..21fd469 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:
+

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

Quoted 10 lines
Documentation/devicetree/bindings/arm/xen.txt +10 -0
+- clocks: one or more clocks to be registered.
+  Xen hypervisor drivers might replace native drivers, resulting in
+  clocks not registered by these native drivers. To avoid that these
+  unregistered clocks are disabled by the Linux kernel initialization
+  register them in the hypervisor node.
+  An example for this are the clocks of a serial driver already enabled
+  by the firmware. If the clocks used by the serial hardware interface
+  are not registered by the serial driver itself the serial output
+  might stop once the Linux kernel initialization disables the 'unused'
+  clocks.

The above describes the set of problems, but doesn't set out the actual contract. It also covers a number of Linux implementation details in abstract.

As I commented previously [1], the binding should describe the set of guarantees that you rewquire (e.g. that the clocks must be left as-is, not gated, and their rates left unchanged).

Please describe the specific set of guarantees that you require.

Thanks,
Mark.

[1] http://lists.infradead.org/pipermail/linux-arm-kernel/2016-June/440434.html

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