From patchwork Mon Jul 29 13:02:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 11063773 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 07E48746 for ; Mon, 29 Jul 2019 13:02:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EAEEC287FE for ; Mon, 29 Jul 2019 13:02:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D462728818; Mon, 29 Jul 2019 13:02:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 587B0287FE for ; Mon, 29 Jul 2019 13:02:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: 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: List-Owner; bh=Eh3R75IubsBfHL0qX66KQlwLwhjh43GoeK4SlDyuHgM=; b=Xnhi9rSWD9RBHB 3V6N+3Qkb5t9Mdt0Bpr/O5IiyMOe08NzzBnA5CwXWs1IAhc7XYCo4dEFruFusLeTij6OQ/p46/6g0 pfdunZVFGrlhbGXrZYx/1VNb29YYCu5ykVcVrFItH80rAuBBL5hRugSt5ABjme3QWXjCgqlQ9kcCm nSOnFy58YeyHdLAhoFhhKNjdmcyzVF1bhdDZQlxKzpIeRJTh0GTAnKx5J2DcA4n99BF9OED2xAf6U Rr4ZmGhbkmVTxOMFR/72vRwfipMXE2msg2zOodAeOm5783e/1DYJ0KQ+bkpkCg5fkWfXc8V/+aQf8 UM7gtGJiV9ohHocXCwjg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hs5IW-000855-8E; Mon, 29 Jul 2019 13:02:40 +0000 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hs5II-0007mM-2m for linux-arm-kernel@lists.infradead.org; Mon, 29 Jul 2019 13:02:28 +0000 Received: by mail-wm1-x343.google.com with SMTP id v15so53798587wml.0 for ; Mon, 29 Jul 2019 06:02:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EvlHbCW1OevHbW9Yaby9CFqayEK2s/Y2m4Jve2BO5WQ=; b=VlPXaYyPE4XBjSsfVxe3EjW4kowH8F7+G6YW+blqO2MW2TSUgeQr0Zuos0Ma6FWy/Q 5jcd3ND8KK+L+x0oslsy145/BK7NM9ViNdZo/8QCWFQprAkPDSwl2KYfBBp6HiI2qZE2 rdQyfzIZwe0u/l9+AyZKwG+LVikNAaoJwCMevQEkp+n1IpRQXYiF2NnpIB2iXNBQZ6KF 94G4LF7tuhl/TLiFfMZ9THMM5mSQLg+tdfLsLD0x1JagkBkV2Q9sc7UV4TzvAvJyZDgf k8pu5zAAvVwvgZi7bvs7ogdjx7dL6M3AZ42kEuUVUXwcGX03X4tQAA/PN7iXN/iAcahm iOew== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=EvlHbCW1OevHbW9Yaby9CFqayEK2s/Y2m4Jve2BO5WQ=; b=q+DfiEGO7DfpcnScppfvyAC0R7ZkYLiOmSacmcLuajNHwPLBnzxftSxsHsl4xVutwI afDMZ6HnLvKxDPm1Ch6QZzLCqgb3In4lSOlHzqXXSTArTi14a/WEhjNh5OAcRDJsAcSQ 40AeHWuH17oWgHdXEfpNwUqOPuvXmGyPDBJYV9ZuhUCDjqf73CqkieGqQZxifof42hmI aaj6b1YVvhgGmen8R/f7NEuYPfx/CMwOyICd8kiBS99vsX6GNl7Ha84byvWWp0oE94hx fIk9kSu1usdTc46cV8MFxncHlE0n7T65PttcFncDHZFtb1VA+jWwrav/8mT4pR1yeLvz MwEw== X-Gm-Message-State: APjAAAUXlLPqcVXqC2LOzw2t4CarvHPd3eadc15l8uZ23tML+E3wg7Af DzzjbW6iHhpNkzqDtrp3STlJOQ== X-Google-Smtp-Source: APXvYqwQo1q5iaW3jvl4f3ZJ8VQMUpxNO5ykvWK67eymaccK4cp71AzuQkWF8mYx0Mt+HvpBngFHmw== X-Received: by 2002:a7b:c1c1:: with SMTP id a1mr104511842wmj.31.1564405343272; Mon, 29 Jul 2019 06:02:23 -0700 (PDT) Received: from bender.baylibre.local (lmontsouris-657-1-212-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.gmail.com with ESMTPSA id x185sm52990545wmg.46.2019.07.29.06.02.22 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 29 Jul 2019 06:02:22 -0700 (PDT) From: Neil Armstrong To: khilman@baylibre.com Subject: [PATCH 1/2] soc: amlogic: meson-clk-measure: protect measure with a mutex Date: Mon, 29 Jul 2019 15:02:17 +0200 Message-Id: <20190729130218.6635-2-narmstrong@baylibre.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729130218.6635-1-narmstrong@baylibre.com> References: <20190729130218.6635-1-narmstrong@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190729_060226_128063_02F417BD X-CRM114-Status: GOOD ( 12.15 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Martin Blumenstingl , linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Neil Armstrong Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP In order to protect clock measuring when multiple process asks for a measure, protect the main measure function with mutexes. Reviewed-by: Kevin Hilman Reviewed-by: Martin Blumenstingl Signed-off-by: Neil Armstrong --- drivers/soc/amlogic/meson-clk-measure.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/soc/amlogic/meson-clk-measure.c b/drivers/soc/amlogic/meson-clk-measure.c index 19d4cbc93a17..c470e24f1dfa 100644 --- a/drivers/soc/amlogic/meson-clk-measure.c +++ b/drivers/soc/amlogic/meson-clk-measure.c @@ -11,6 +11,8 @@ #include #include +static DEFINE_MUTEX(measure_lock); + #define MSR_CLK_DUTY 0x0 #define MSR_CLK_REG0 0x4 #define MSR_CLK_REG1 0x8 @@ -360,6 +362,10 @@ static int meson_measure_id(struct meson_msr_id *clk_msr_id, unsigned int val; int ret; + ret = mutex_lock_interruptible(&measure_lock); + if (ret) + return ret; + regmap_write(priv->regmap, MSR_CLK_REG0, 0); /* Set measurement duration */ @@ -377,8 +383,10 @@ static int meson_measure_id(struct meson_msr_id *clk_msr_id, ret = regmap_read_poll_timeout(priv->regmap, MSR_CLK_REG0, val, !(val & MSR_BUSY), 10, 10000); - if (ret) + if (ret) { + mutex_unlock(&measure_lock); return ret; + } /* Disable */ regmap_update_bits(priv->regmap, MSR_CLK_REG0, MSR_ENABLE, 0); @@ -386,6 +394,8 @@ static int meson_measure_id(struct meson_msr_id *clk_msr_id, /* Get the value in multiple of gate time counts */ regmap_read(priv->regmap, MSR_CLK_REG2, &val); + mutex_unlock(&measure_lock); + if (val >= MSR_VAL_MASK) return -EINVAL; From patchwork Mon Jul 29 13:02:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 11063769 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3D51F746 for ; Mon, 29 Jul 2019 13:02:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2CF51287E7 for ; Mon, 29 Jul 2019 13:02:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 19F03287FE; Mon, 29 Jul 2019 13:02:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9B1FE287EF for ; Mon, 29 Jul 2019 13:02:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: 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: List-Owner; bh=MQQ3d0FW/B2j6oploK2vzmPCWu4/B6yH8rDmSciD9kw=; b=LClPMJu0Gmc9Xb Mhhv1rzT6cWERLkJ90rxusvpqcRnzZYWsx2PnB6yML7rhNc+9su3YVsCQW3a1JAo0ZgpIwMeb/QcW a4KpL5Uky22zcm3WrciLyV3ntKXLT8apatl77ATVlnyXoIIhakqlqE4iiGEQeXdYoXXBUoyiYusEi Dbbm2UJNLyWsEUvAyGsXqVIsWKC2x5hZeGh+wZDTpo85lEiZ3Wimy5l6g/wb0iX/Rd23wOlJp0Vz9 L8ALjlE5ss+Ef9ggpVRf5ZJuRPS9tj4PPtcjmgir+VR/CW6HWijwGEqDP1WdopnBHO1vtWMG3aSWF RZ+KKOgCyadP2T/hUuhQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hs5IM-0007r4-R6; Mon, 29 Jul 2019 13:02:30 +0000 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hs5IH-0007mK-FC for linux-arm-kernel@lists.infradead.org; Mon, 29 Jul 2019 13:02:28 +0000 Received: by mail-wr1-x442.google.com with SMTP id n9so36673464wrr.4 for ; Mon, 29 Jul 2019 06:02:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Zpr851HMr2C/6wpW/fjgX4pS+dl7PCTuVx/DMDxcThc=; b=IVmIf78IJU5aRgsX2G1HqgHG4gUMk87UdaGXrM/qg9kxvtuyVkZmYR9x8WLK1ULFTX FokG4NTFEjm0kKUPe3tSO9hQutVLy/ZedxMBjSE4rtgVEvXBXl61eOmb6eFoDItT+xRz Boi14E4dWXIKuLzjdYF8XILxCFAWcMVrBUSKAJ61JB0cMegkLGHCzkuQY5619R1waaB9 04efrurE2Vc6FsrXDIfsXbXNy7nKclZr8tlRdDuspWUFOuo7stK6JVgofieof7f2yOky febOvPdFwy+EU+Bkfyi7P/ae3GplqN+L0+tLOfv8gn29/UfcmzLh+UTQN4JdFsKiN+kd +oLA== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=Zpr851HMr2C/6wpW/fjgX4pS+dl7PCTuVx/DMDxcThc=; b=b/tTYGIRrAk1GaE1Jx06jfD2edZH54msLDE5QxIU12RjpM0rwvvXjhnYcQz+9itw7k TfUMfWSuO4pb5+CwMcINFCkKvlRaFASrkQyxbTw/NK692O1BxKhagBPCbwtpnbgN+vdM FFaGGMAiHeZemtDthIxDPxu2sC5sn4WH4Fu9X8bR493Zppc4O5Tl21y5GTpP2TrvXc6+ 0Hd1dIILeC0dBIgmWOFJnch5ZBuKlKe9y6p0o50mURSsScgTbt5HKTeE+ucnI0XrZ6VF LyLNgz4CNz/NshmpDNyxw3Pp3vnluCrpOSkZXyzS2Z6x6HEbr5YNCf9Z3id8w3ItW/48 afjg== X-Gm-Message-State: APjAAAVvAehBiTT/n1/CZy777QWSHEkmFGHUCl+mPOZqMlPk4KOwNu5c BjnzRoFCeGVDLMLaA5GVO/uPwA== X-Google-Smtp-Source: APXvYqxoSLVFIeYxYdV5hYNuyqLN4MINVeUl04PX1hyBeSvXWR3XeJJNee8SGZulXnrDLKFW4GD1Uw== X-Received: by 2002:adf:df8b:: with SMTP id z11mr64212411wrl.62.1564405344004; Mon, 29 Jul 2019 06:02:24 -0700 (PDT) Received: from bender.baylibre.local (lmontsouris-657-1-212-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.gmail.com with ESMTPSA id x185sm52990545wmg.46.2019.07.29.06.02.23 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 29 Jul 2019 06:02:23 -0700 (PDT) From: Neil Armstrong To: khilman@baylibre.com Subject: [PATCH 2/2] soc: amlogic: meson-clk-measure: add G12B second cluster cpu clk Date: Mon, 29 Jul 2019 15:02:18 +0200 Message-Id: <20190729130218.6635-3-narmstrong@baylibre.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729130218.6635-1-narmstrong@baylibre.com> References: <20190729130218.6635-1-narmstrong@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190729_060225_510536_52BA14BE X-CRM114-Status: UNSURE ( 9.06 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Martin Blumenstingl , linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Neil Armstrong Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Add the G12B second CPU cluster CPU and SYS_PLL measure IDs. These IDs returns 0Hz on G12A. Reviewed-by: Kevin Hilman Reviewed-by: Martin Blumenstingl Signed-off-by: Neil Armstrong --- drivers/soc/amlogic/meson-clk-measure.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/soc/amlogic/meson-clk-measure.c b/drivers/soc/amlogic/meson-clk-measure.c index c470e24f1dfa..f09b404b39d3 100644 --- a/drivers/soc/amlogic/meson-clk-measure.c +++ b/drivers/soc/amlogic/meson-clk-measure.c @@ -324,6 +324,8 @@ static struct meson_msr_id clk_msr_g12a[CLK_MSR_MAX] = { CLK_MSR_ID(84, "co_tx"), CLK_MSR_ID(89, "hdmi_todig"), CLK_MSR_ID(90, "hdmitx_sys"), + CLK_MSR_ID(91, "sys_cpub_div16"), + CLK_MSR_ID(92, "sys_pll_cpub_div16"), CLK_MSR_ID(94, "eth_phy_rx"), CLK_MSR_ID(95, "eth_phy_pll"), CLK_MSR_ID(96, "vpu_b"),