From patchwork Tue Jan 22 19:58:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Shtylyov X-Patchwork-Id: 10776199 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 32B9F1390 for ; Tue, 22 Jan 2019 19:58:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 214A72B95E for ; Tue, 22 Jan 2019 19:58:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 155E62B96A; Tue, 22 Jan 2019 19:58:46 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AFFD92B95E for ; Tue, 22 Jan 2019 19:58:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726035AbfAVT6p (ORCPT ); Tue, 22 Jan 2019 14:58:45 -0500 Received: from mail-lf1-f67.google.com ([209.85.167.67]:41354 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726009AbfAVT6o (ORCPT ); Tue, 22 Jan 2019 14:58:44 -0500 Received: by mail-lf1-f67.google.com with SMTP id c16so19013367lfj.8 for ; Tue, 22 Jan 2019 11:58:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cogentembedded-com.20150623.gappssmtp.com; s=20150623; h=subject:from:to:references:organization:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=WPaa9s6qqwjVhXcdKFVgWx7xVGXgDKS5Jm7FG/EZ3tA=; b=n9KghBzWI8PTppkBzsmCk5CHdK/bybGvtVxBBWFhVF8zyuLj91Uu7192wL+Kj4ls/G yNVYt+PxxK9oIxfe8GR6+PvgXCXfDATyn6e92Ja3T9QDVSNg2dpb7eD8OnrHGV0zNz9A YqA6v66IOoW3g8zxCRHXCuRsVid2VJr7O5sUc1qpweS12SDY5rBw8ya0LHOsWnlHjlzM lzZE490f4jmbtddb7cnL62EgqwdBwuIlfZl/BF/FC/dXWO4XUGA6R1DzNhbVah5dAF+e EIahuKWTfka7Rq2DxPLZW08YqrhunmyEVtsHJ3x9Hw0tBTuZZI45WxHQ0I0sQQdgBzDq Ndkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:references:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=WPaa9s6qqwjVhXcdKFVgWx7xVGXgDKS5Jm7FG/EZ3tA=; b=qKgCV23woKJk5hZKzBudXXEo4t25dOBpOi/iaKdfyI4PGkpXCWrK5fkQDfAKe4GXRH P+fxQnQVs3f1yeG5X2D0Hm4B1RbBwkVVOan4GAp6S0YDLSvzoJKCYipYJ8PxAdaS4wvO YLqX6NKQzBLnNCE3NuiiaR0BsYWuUkJg1wnROHi0X+sV8DulsE9FJ+qiFuEaIUfoorw/ biVVIirJg+4NUZa6KFKdVdtPY4UlROO5OZ+Lm7Ed3F/E1UaxPzxZAl4ptJjulvUlbxVK RCOSKciwX8J9znBIl7VRSXJRk6z9rQT+foHoB2exBYzUxOb7d+WT92jXZ8l/grW5fuIP 6dfQ== X-Gm-Message-State: AJcUukdHF0p59wymeJ3Lqs8yDow9ATd+EohGzGt8+Dh4aMDloC9SZTL3 1MUZ9TJN6zOpwNzTLEexrtiv1T4/2qw= X-Google-Smtp-Source: ALg8bN7AQg4mcsSp/aQ3IEoygBAGBVYQMebZirolhKa6Zq82rtuGtv4Bf+VpW1N007yuzukgNs5HbA== X-Received: by 2002:a19:8f45:: with SMTP id r66mr23186965lfd.9.1548187120506; Tue, 22 Jan 2019 11:58:40 -0800 (PST) Received: from wasted.cogentembedded.com ([31.173.82.69]) by smtp.gmail.com with ESMTPSA id m13-v6sm147515ljg.56.2019.01.22.11.58.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Jan 2019 11:58:39 -0800 (PST) Subject: [PATCH v3 2/4] clk: renesas: rcar-gen3-cpg: add spinlock From: Sergei Shtylyov To: linux-renesas-soc@vger.kernel.org, Michael Turquette , Stephen Boyd , Geert Uytterhoeven , linux-clk@vger.kernel.org References: Organization: Cogent Embedded Message-ID: <8a630f60-c5a1-de98-f80a-40404199d8bd@cogentembedded.com> Date: Tue, 22 Jan 2019 22:58:38 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: Content-Language: en-MW Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Protect the CPG register read-modify-write sequence with a spinlock. Signed-off-by: Sergei Shtylyov Reviewed-by: Geert Uytterhoeven --- Changes in version 3: - refreshed the patch; - added Geert's tag. Changes in version 2: - new patch. drivers/clk/renesas/rcar-gen3-cpg.c | 8 ++++++++ 1 file changed, 8 insertions(+) Index: renesas-drivers/drivers/clk/renesas/rcar-gen3-cpg.c =================================================================== --- renesas-drivers.orig/drivers/clk/renesas/rcar-gen3-cpg.c +++ renesas-drivers/drivers/clk/renesas/rcar-gen3-cpg.c @@ -30,14 +30,19 @@ #define CPG_RCKCR_CKSEL BIT(15) /* RCLK Clock Source Select */ +static spinlock_t cpg_lock; + static void cpg_reg_modify(void __iomem *reg, u32 clear, u32 set) { + unsigned long flags; u32 val; + spin_lock_irqsave(&cpg_lock, flags); val = readl(reg); val &= ~clear; val |= set; writel(val, reg); + spin_unlock_irqrestore(&cpg_lock, flags); }; struct cpg_simple_notifier { @@ -615,5 +620,8 @@ int __init rcar_gen3_cpg_init(const stru if (attr) cpg_quirks = (uintptr_t)attr->data; pr_debug("%s: mode = 0x%x quirks = 0x%x\n", __func__, mode, cpg_quirks); + + spin_lock_init(&cpg_lock); + return 0; }