From: Andrea Merello <andrea.merello@gmail.com> To: tglx@linutronix.de, daniel.lezcano@linaro.org Cc: "Andrea Merello" <andrea.merello@gmail.com>, "Patrice Chotard" <patrice.chotard@st.com>, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, "Michal Simek" <michal.simek@xilinx.com>, "Sören Brinkmann" <soren.brinkmann@xilinx.com> Subject: [PATCH v2 0/2] Fix missing entropy on Zynq arch due to get_cycles() not supported Date: Tue, 6 Apr 2021 15:00:43 +0200 [thread overview] Message-ID: <20210406130045.15491-1-andrea.merello@gmail.com> (raw) Changes wrt v1: - rebased on latest kernel tree - fix cover letter: does -> doesn't A real-world problem has been seen with a Zynq-based board running Debian 10, where ssh daemon takes a really long time to come up at boot. This is due to lack of random numbers. Since commit 50ee7529ec450 ("random: try to actively add entropy rather than passively wait for it") we try to generate entropy whenever we are in short of random numbers and someone needs them. This trick works only when CPU cycle counter is available. On ARM this means that get_cycles() works and in turn read_current_timer() works. Zynq HW includes two "cadence TTC" timers and the "ARM global timer". All these pieces of HW are fed by the CPU clock, which dynamically changes whenever CPU frequency scaling is enabled. In timer-cadence-ttc driver this scenario is handled by looking at parent clock changes and adjusting things when required. This is the only usable clocksource when CPU frequency scaling is in use. arm_global_timer driver is disabled in Kconfig when CPU_FREQ is enabled for Zynq arch. Unfortunately timer-cadence-ttc driver doesn't register itself via register_current_timer_delay() and that ultimately ends up in get_cycles() to always return zero, causing the aforementioned lack of entropy problem. I believe that the reason for this is because Cadence TTC counter on Zynq silicon is only 16-bit wide. This patchset works around this by implementing in ARM global timer driver a mechanism to compensate for parent clock variations, similarly to what it's done in Cadence TTC timer driver, so that it can be used together with CPU frequency scaling on Zynq arch. This proved to finally fix the problem on my Zynq-based Z-turn board. Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Cc: Patrice Chotard <patrice.chotard@st.com> Cc: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org Cc: Michal Simek <michal.simek@xilinx.com> Cc: Sören Brinkmann <soren.brinkmann@xilinx.com> Andrea Merello (2): clocksource: arm_global_timer: implement rate compensation whenever source clock changes arm: zynq: don't disable CONFIG_ARM_GLOBAL_TIMER due to CONFIG_CPU_FREQ anymore arch/arm/mach-zynq/Kconfig | 2 +- drivers/clocksource/Kconfig | 14 +++ drivers/clocksource/arm_global_timer.c | 122 +++++++++++++++++++++++-- 3 files changed, 127 insertions(+), 11 deletions(-) -- 2.17.1
WARNING: multiple messages have this Message-ID (diff)
From: Andrea Merello <andrea.merello@gmail.com> To: tglx@linutronix.de, daniel.lezcano@linaro.org Cc: "Andrea Merello" <andrea.merello@gmail.com>, "Patrice Chotard" <patrice.chotard@st.com>, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, "Michal Simek" <michal.simek@xilinx.com>, "Sören Brinkmann" <soren.brinkmann@xilinx.com> Subject: [PATCH v2 0/2] Fix missing entropy on Zynq arch due to get_cycles() not supported Date: Tue, 6 Apr 2021 15:00:43 +0200 [thread overview] Message-ID: <20210406130045.15491-1-andrea.merello@gmail.com> (raw) Changes wrt v1: - rebased on latest kernel tree - fix cover letter: does -> doesn't A real-world problem has been seen with a Zynq-based board running Debian 10, where ssh daemon takes a really long time to come up at boot. This is due to lack of random numbers. Since commit 50ee7529ec450 ("random: try to actively add entropy rather than passively wait for it") we try to generate entropy whenever we are in short of random numbers and someone needs them. This trick works only when CPU cycle counter is available. On ARM this means that get_cycles() works and in turn read_current_timer() works. Zynq HW includes two "cadence TTC" timers and the "ARM global timer". All these pieces of HW are fed by the CPU clock, which dynamically changes whenever CPU frequency scaling is enabled. In timer-cadence-ttc driver this scenario is handled by looking at parent clock changes and adjusting things when required. This is the only usable clocksource when CPU frequency scaling is in use. arm_global_timer driver is disabled in Kconfig when CPU_FREQ is enabled for Zynq arch. Unfortunately timer-cadence-ttc driver doesn't register itself via register_current_timer_delay() and that ultimately ends up in get_cycles() to always return zero, causing the aforementioned lack of entropy problem. I believe that the reason for this is because Cadence TTC counter on Zynq silicon is only 16-bit wide. This patchset works around this by implementing in ARM global timer driver a mechanism to compensate for parent clock variations, similarly to what it's done in Cadence TTC timer driver, so that it can be used together with CPU frequency scaling on Zynq arch. This proved to finally fix the problem on my Zynq-based Z-turn board. Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Cc: Patrice Chotard <patrice.chotard@st.com> Cc: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org Cc: Michal Simek <michal.simek@xilinx.com> Cc: Sören Brinkmann <soren.brinkmann@xilinx.com> Andrea Merello (2): clocksource: arm_global_timer: implement rate compensation whenever source clock changes arm: zynq: don't disable CONFIG_ARM_GLOBAL_TIMER due to CONFIG_CPU_FREQ anymore arch/arm/mach-zynq/Kconfig | 2 +- drivers/clocksource/Kconfig | 14 +++ drivers/clocksource/arm_global_timer.c | 122 +++++++++++++++++++++++-- 3 files changed, 127 insertions(+), 11 deletions(-) -- 2.17.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next reply other threads:[~2021-04-06 13:00 UTC|newest] Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-04-06 13:00 Andrea Merello [this message] 2021-04-06 13:00 ` [PATCH v2 0/2] Fix missing entropy on Zynq arch due to get_cycles() not supported Andrea Merello 2021-04-06 13:00 ` [PATCH v2 1/2] clocksource: arm_global_timer: implement rate compensation whenever source clock changes Andrea Merello 2021-04-06 13:00 ` Andrea Merello 2021-06-10 13:01 ` Daniel Lezcano 2021-06-10 13:01 ` Daniel Lezcano 2021-06-10 13:49 ` Patrice CHOTARD 2021-06-10 13:49 ` Patrice CHOTARD 2021-06-18 16:03 ` [tip: timers/core] clocksource/drivers/arm_global_timer: Implement " tip-bot2 for Andrea Merello 2022-10-17 8:03 ` [BUG] [PATCH v2 1/2] clocksource: arm_global_timer: implement " Johan Jonker 2022-10-17 8:03 ` Johan Jonker 2022-10-17 8:03 ` Johan Jonker 2022-10-27 13:37 ` Andrea Merello 2022-10-27 13:37 ` Andrea Merello 2022-10-27 13:37 ` Andrea Merello 2022-10-30 14:50 ` Johan Jonker 2022-10-30 14:50 ` Johan Jonker 2022-10-30 14:50 ` Johan Jonker 2022-10-30 15:09 ` Johan Jonker 2022-10-30 15:09 ` Johan Jonker 2022-10-30 15:09 ` Johan Jonker 2021-04-06 13:00 ` [PATCH v2 2/2] arm: zynq: don't disable CONFIG_ARM_GLOBAL_TIMER due to CONFIG_CPU_FREQ anymore Andrea Merello 2021-04-06 13:00 ` Andrea Merello 2021-06-18 16:03 ` [tip: timers/core] " tip-bot2 for Andrea Merello 2021-04-27 14:19 ` [PATCH v2 0/2] Fix missing entropy on Zynq arch due to get_cycles() not supported Michal Simek 2021-04-27 14:19 ` Michal Simek
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20210406130045.15491-1-andrea.merello@gmail.com \ --to=andrea.merello@gmail.com \ --cc=daniel.lezcano@linaro.org \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=michal.simek@xilinx.com \ --cc=patrice.chotard@st.com \ --cc=soren.brinkmann@xilinx.com \ --cc=tglx@linutronix.de \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.