Message ID | 20210217110709.17250-1-andrea.merello@gmail.com (mailing list archive) |
---|---|
Headers | show
Return-Path: <SRS0=Q6KY=HT=lists.infradead.org=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@kernel.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9570DC433E6 for <linux-arm-kernel@archiver.kernel.org>; Wed, 17 Feb 2021 11:08:42 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 52FD564DEC for <linux-arm-kernel@archiver.kernel.org>; Wed, 17 Feb 2021 11:08:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 52FD564DEC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=kQ27WInTEPUiXH+xU2BKpDO+k0j1pQs1n/ubjF+yAG0=; b=UBwmjZypDx5Aswx6AcDObRNQ/f D1KvBUsO7JU1BIlF0ZiZwI8MC3csPAQoDn0tp0ZS4Kk6D3b5fXrsunkIHf0RFsjfpI85Iq3pfFI5L PX8pCxG9Okmk4NXHdJNT9DGvm3wqeJSf8P7ug2EruWnsIgCg7NonJYj9i2ziLi2T96CmqAodT1J1I SimAmGDerCX+/qgu/bq4t4Ab5w3Ct7QwV/qO/pkxkTNLSuAyiDvJeWzBU9z9HfOOMBJCOo3IojruL KLdHn3ruKhrQn6CkBpFRC06tvH7LWGa6FfW9uHu3j03nJR2NLPepdQvY2/oSMBEIX9tJjdrzvA+DY lGNaSjzg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lCKfv-0007u0-Fg; Wed, 17 Feb 2021 11:07:19 +0000 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1lCKfs-0007sa-GQ for linux-arm-kernel@lists.infradead.org; Wed, 17 Feb 2021 11:07:17 +0000 Received: by mail-wm1-x336.google.com with SMTP id i7so982704wmb.0 for <linux-arm-kernel@lists.infradead.org>; Wed, 17 Feb 2021 03:07:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=0viQUj5Dr40nhdd+nbH060vF+sT9j2nptYrLWR14fgQ=; b=inXAa2Oc3moxxLXWr3kSM1NnCVXHDIZJdoCbdo/Otczc2T55Yld5fb0Xcz6tg2GchS Yhn5FPcXkRsE0L4mHJM+u8o4WAxye0KqBCxxqxc88n/gFD3a1OfQZEYIh1bTSUgs7Mdg FQj0tH9DTUKwJur5CsX0JzDw/0kBCfz2lokqNgZYAoPTna6H8LVufUeeLazj3TYbYHvc sm6McUnM6kqWkbzUuOGaxTS4O7cP3pc6iK7Fs4PqqLE5mxA5f2MDAeK6aUM/IVCB6F6Z aPg70gSaHnnlDkLO8xZfqU08ClFEtOaHH2ZwU6tONh5QHoFnhouS6AXEswBBf0R2dKXS p+JA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=0viQUj5Dr40nhdd+nbH060vF+sT9j2nptYrLWR14fgQ=; b=WNCV5IQKWEUIeBOAvPjs3L9Fxgt+VLcyczSKvM1tJ6ZTDn02M8CYsvUQQvKUxzlI3t 5Y5vSDXdFihywFUqI8W1ydhGohOsocJDe8p9zcRnkvuoG2KNJ0gHDvmqNHwrFmKNw47i rzfy+PsqVVM+4L/cYQbu+kXph1SC4Tqz64YiHmb9nqoJldgVNZj7q+RH2/xhkNnTBiJ9 uoA07LvM8Hog8eJbTRt5OLV9eMzCEcqHxIsPbI6j+0msuQeC6uZ7NU9MjQdXGB4EHpIr +LODc+Vzg82YbhOWdXHFYAi03UqXFWKmpE/MKPrLpDpJxRldt/EzPJmSQtU2v/s0F8EX /0ag== X-Gm-Message-State: AOAM5332vGkbrv6ryRS3neRtDOm4jHS3/LvFQZl0SWJqvkclB+SMFRsd hjblC/i1sM21CUbFixYnZO0= X-Google-Smtp-Source: ABdhPJwcMRjozqtTz0qQ9Hsbqsaw5xZcXHmRuIkFQHT8j1PJ/vVSRVS5HYYSD7mYLWz5NXF+5gwi/A== X-Received: by 2002:a7b:c055:: with SMTP id u21mr6894105wmc.68.1613560033609; Wed, 17 Feb 2021 03:07:13 -0800 (PST) Received: from poker.lan (static.2-229-210-222.ip198.fastwebnet.it. [2.229.210.222]) by smtp.gmail.com with ESMTPSA id y1sm3594073wrr.41.2021.02.17.03.07.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Feb 2021 03:07:13 -0800 (PST) From: Andrea Merello <andrea.merello@gmail.com> To: tglx@linutronix.de, daniel.lezcano@linaro.org Subject: [PATCH 0/2] Fix missing entropy on Zynq arch due to get_cycles() not supported Date: Wed, 17 Feb 2021 12:07:07 +0100 Message-Id: <20210217110709.17250-1-andrea.merello@gmail.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210217_060716_570051_15AD08AC X-CRM114-Status: GOOD ( 13.38 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: <linux-arm-kernel.lists.infradead.org> List-Unsubscribe: <http://lists.infradead.org/mailman/options/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe> List-Archive: <http://lists.infradead.org/pipermail/linux-arm-kernel/> List-Post: <mailto:linux-arm-kernel@lists.infradead.org> List-Help: <mailto:linux-arm-kernel-request@lists.infradead.org?subject=help> List-Subscribe: <http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe> Cc: Andrea Merello <andrea.merello@gmail.com>, linux-kernel@vger.kernel.org, Michal Simek <michal.simek@xilinx.com>, Patrice Chotard <patrice.chotard@st.com>, linux-arm-kernel@lists.infradead.org, =?utf-8?q?S=C3=B6ren_Brinkmann?= <soren.brinkmann@xilinx.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Sender: "linux-arm-kernel" <linux-arm-kernel-bounces@lists.infradead.org> Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org |
Series |
Fix missing entropy on Zynq arch due to get_cycles() not supported
|
expand
|
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 does 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