From patchwork Thu Mar 30 21:01:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 96328 Delivered-To: patches@linaro.org Received: by 10.140.89.233 with SMTP id v96csp425806qgd; Thu, 30 Mar 2017 14:01:37 -0700 (PDT) X-Received: by 10.99.112.87 with SMTP id a23mr1113437pgn.7.1490907697785; Thu, 30 Mar 2017 14:01:37 -0700 (PDT) Return-Path: Received: from mail-pg0-x236.google.com (mail-pg0-x236.google.com. [2607:f8b0:400e:c05::236]) by mx.google.com with ESMTPS id u123si2930838pgc.280.2017.03.30.14.01.37 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Mar 2017 14:01:37 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c05::236 as permitted sender) client-ip=2607:f8b0:400e:c05::236; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c05::236 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by mail-pg0-x236.google.com with SMTP id x125so50223455pgb.0 for ; Thu, 30 Mar 2017 14:01:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=NaEMBw5an7fELpQZPIdsqKOS9fnLVthCAGi34evtNg4=; b=XzvVBg6pqZPxtTOvIqE5AuigO970Tivahl6YbE2KxEVo0q3YSryts3JQqiEfzNkKbE /Et8BBfoWhzXhxdPwPJxHmz/Q3DGFT+Emx6tTVLSsKegO/i8A0gCK9Ab0sg6AjWImGIM D9KagDceIWtW+6WXccpuNx32W+nwS0g9ddNPk= 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; bh=NaEMBw5an7fELpQZPIdsqKOS9fnLVthCAGi34evtNg4=; b=LFdNUmHHyYgwq7k/XwhK/9IkchhwnOTVkt9BRftsfJfE2lZgz8w1lw6h+aILGWWxnu dF2HssQMwJ+uVg5JWgvfGwRkPicAD7xHUtCb3VKdqAJJG/zAX4B91FZsVcmk4uIFe4di yKDRyyUPYlPomBJd+q4H7ChqqOGWZcW/pzSoTIZgX+LC+uxeD9PsxYaQRR5ejzshSCwH iQellb41rQj/YY86oTzZMX2dHIbl0Cnf0xCtmXXq9a5cbgIM9coz+L9ALXhiFezLuIpj pQfuHWswmV+4zIo7ZzCgRuwp9DlUuXGueANL1uw0IsbCwTSsV594yY/q899IwP6HcN32 yaGw== X-Gm-Message-State: AFeK/H12HY6kIQhUwgdw5cJGVaro3amABtpoSDUCuBhQc7b73iRXDKf/FLYNk8cn/vgszDf82NY= X-Received: by 10.98.86.152 with SMTP id h24mr1180854pfj.184.1490907697461; Thu, 30 Mar 2017 14:01:37 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:1002:83f0:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id y7sm6162626pfk.93.2017.03.30.14.01.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 30 Mar 2017 14:01:36 -0700 (PDT) From: John Stultz To: lkml Cc: Nicolai Stange , Ingo Molnar , Thomas Gleixner , Daniel Lezcano , Richard Cochran , Prarit Bhargava , Stephen Boyd , John Stultz Subject: [PATCH 3/9] clocksource: em_sti: Split clock prepare and enable steps Date: Thu, 30 Mar 2017 14:01:18 -0700 Message-Id: <1490907684-11186-4-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1490907684-11186-1-git-send-email-john.stultz@linaro.org> References: <1490907684-11186-1-git-send-email-john.stultz@linaro.org> From: Nicolai Stange Currently, the em_sti driver prepares and enables the needed clock in em_sti_enable(), potentially called through its clockevent device's ->set_state_oneshot(). However, the clk_prepare() step may sleep whereas tick_program_event() and thus, ->set_state_oneshot(), can be called in atomic context. Split the clk_prepare_enable() in em_sti_enable() into two steps: - prepare the clock at device probing via clk_prepare() - and enable it in em_sti_enable() via clk_enable(). Slightly reorder resource initialization in em_sti_probe() in order to facilitate error handling in later patches. Cc: Ingo Molnar Cc: Thomas Gleixner Cc: Daniel Lezcano Cc: Richard Cochran Cc: Prarit Bhargava Cc: Stephen Boyd Signed-off-by: Nicolai Stange Signed-off-by: John Stultz --- drivers/clocksource/em_sti.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) -- 2.7.4 diff --git a/drivers/clocksource/em_sti.c b/drivers/clocksource/em_sti.c index aff87df..6c0955a 100644 --- a/drivers/clocksource/em_sti.c +++ b/drivers/clocksource/em_sti.c @@ -78,7 +78,7 @@ static int em_sti_enable(struct em_sti_priv *p) int ret; /* enable clock */ - ret = clk_prepare_enable(p->clk); + ret = clk_enable(p->clk); if (ret) { dev_err(&p->pdev->dev, "cannot enable clock\n"); return ret; @@ -107,7 +107,7 @@ static void em_sti_disable(struct em_sti_priv *p) em_sti_write(p, STI_INTENCLR, 3); /* stop clock */ - clk_disable_unprepare(p->clk); + clk_disable(p->clk); } static u64 em_sti_count(struct em_sti_priv *p) @@ -303,6 +303,7 @@ static int em_sti_probe(struct platform_device *pdev) struct em_sti_priv *p; struct resource *res; int irq; + int ret; p = devm_kzalloc(&pdev->dev, sizeof(*p), GFP_KERNEL); if (p == NULL) @@ -323,6 +324,13 @@ static int em_sti_probe(struct platform_device *pdev) if (IS_ERR(p->base)) return PTR_ERR(p->base); + if (devm_request_irq(&pdev->dev, irq, em_sti_interrupt, + IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING, + dev_name(&pdev->dev), p)) { + dev_err(&pdev->dev, "failed to request low IRQ\n"); + return -ENOENT; + } + /* get hold of clock */ p->clk = devm_clk_get(&pdev->dev, "sclk"); if (IS_ERR(p->clk)) { @@ -330,11 +338,10 @@ static int em_sti_probe(struct platform_device *pdev) return PTR_ERR(p->clk); } - if (devm_request_irq(&pdev->dev, irq, em_sti_interrupt, - IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING, - dev_name(&pdev->dev), p)) { - dev_err(&pdev->dev, "failed to request low IRQ\n"); - return -ENOENT; + ret = clk_prepare(p->clk); + if (ret < 0) { + dev_err(&pdev->dev, "cannot prepare clock\n"); + return ret; } raw_spin_lock_init(&p->lock);