From patchwork Tue Dec 4 19:49:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Shtylyov X-Patchwork-Id: 10712567 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 10FB1109C for ; Tue, 4 Dec 2018 19:49:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 045402C57D for ; Tue, 4 Dec 2018 19:49:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EC16E2C4F7; Tue, 4 Dec 2018 19:49:49 +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=unavailable 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 94C9A2C4F6 for ; Tue, 4 Dec 2018 19:49:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725874AbeLDTtt (ORCPT ); Tue, 4 Dec 2018 14:49:49 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:37890 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725866AbeLDTts (ORCPT ); Tue, 4 Dec 2018 14:49:48 -0500 Received: by mail-lj1-f194.google.com with SMTP id c19-v6so16082304lja.5 for ; Tue, 04 Dec 2018 11:49:46 -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=/o6KHpko38zQTER6xvHRq4G5yD/Y25AI3XjjTxYj3I8=; b=MJLJckbOE/BwkB6no2+Ogvp5ZYGIUHOKgIbkiYauUESlq7UgcIyEuTCqL/BNs16OqN ekLUuCzqlkmFdfVXzir0rwzPKV97+z7bgbg9JdIhAVcftDadOiU8nt+YzD512ZkrTT/h IOcDICt9NgpZgD0Ui5pO9E1DZJc3u6TtQa9GvX8LlFRZV+bnyZ5PrM5I90+iGzE0sYJN mrxXXG4nWwy6DQHe8y6pJIRXh9Eu3dUxkHQQU7hDuJ1tGhbioMxNdJWXG8sm17ArJGmK MlNhW7H9NXAxLV5GzQ3h2N7ZJUxkVVxnBoVrpjbh4il5JQSmEN9kNG0gUFC31an9gK2N 1w6Q== 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=/o6KHpko38zQTER6xvHRq4G5yD/Y25AI3XjjTxYj3I8=; b=RAfwmgjkbGFP8VbKu4uODkmCGTxnBGe5k+emhYVbGNsp/U08ey/UpNoXIl1Z9SwoWJ MNU3wvDfGsWydjgDZtuTq8khrD1Pvfb3fcuRZIb9WWX+uI92pG2KzSwAkS8Nt4n1pToK rWwHnS6sfCdFYTwciU/oNLy1yiqttfgA5xgH8koGxO3yTwrGtQz+kcIuZ1KjLen1c2QH YcqBeBumGdJMG3iXSRFHNEHiGP2g351+i8afOECAJqZRDqB4LMyTyW/NuUkIbhq1fRSz Cw99O3oPYcJ5k+t2e7ypX+ZbkpGH2C7WKHyHnU57zzRkD3zntuw8AkbHCzkWsPj5vRyx FKpQ== X-Gm-Message-State: AA+aEWYNm4BwXgq363Ln0zddm3DmkcvID6B9QSjF964BzawNtvmUKQba FMBQpsJi4Fm4ALBooiQLuZy++23uJ9Q= X-Google-Smtp-Source: AFSGD/WoQ7Ts7DxWCHlO5ORta/V8fiLPVGzt+oDAghXpZ/KSCn2iXJACVUqSqI0BXu83olfpzTKB7Q== X-Received: by 2002:a2e:80d3:: with SMTP id r19-v6mr13824436ljg.151.1543952985753; Tue, 04 Dec 2018 11:49:45 -0800 (PST) Received: from wasted.cogentembedded.com ([31.173.84.250]) by smtp.gmail.com with ESMTPSA id p21sm539276lfj.10.2018.12.04.11.49.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Dec 2018 11:49:45 -0800 (PST) Subject: [PATCH v2 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: Date: Tue, 4 Dec 2018 22:49:44 +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 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 { @@ -604,5 +609,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; }