Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp6629880yba; Wed, 1 May 2019 16:43:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqzYWRCiGx8TQpkM4cQxlMPHvVC0yWZCOHBWuW3JujCn2A5ki3AZA6aZwNno8PemDI+xc+XH X-Received: by 2002:a63:fb56:: with SMTP id w22mr704578pgj.354.1556754210588; Wed, 01 May 2019 16:43:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556754210; cv=none; d=google.com; s=arc-20160816; b=EysrS3LhyG+IEDVoddECzAGvhRICgQi75qi/lNRG8RRITWDZxYK0Qgls0wNrzoowwA 98KTKR27f0K1cda95dnY6wWx6KJlJNRJWbiZnsKj5ee7Qc+SKW/FcOrllgauK0kkIuoX xd2A8XaIxQX6h/zQcD1bdHgaDSlehR+ar00OCL1NozBqU6p15Ow6dshcjKpc6qJudJxt 0uNcRDf067W6yPSNZh/tn/AzA0ZJRVU4DcnCJ/5xEgnKUc+WtrqFbXyGoutuhoHeN9ve S8df12LxyjXH06jnvesTrWR+diQGvbOcCTsZtIK+mbhB9NIulgowyLrdL2RI4jclwmpN 0jPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9QwYS9bQr6zIIDqya7O/hmsOjlwL0wV6gZaAMteb584=; b=YnzCJ6SDLL6Dl/Nzu3wycmWuxOdaLVSb5bulZGKZluIOQhVN2Sk4mmmbGqqe2gEyxz AgiXy/4zP+59bs/xQE75PYer9+ZCBR0onTCNFT658fv7JvFPnFxUw6EkDRNR5A77x1G3 TXyB5kpNXxjJ94lcpM/FrYjI/KlvHowD769ZFD4tc3w+ugf9Y8xpZ1/dtyUp4wVs5QqA Fav3plldhFDVoY1ZzM4dYJQpONrmjf4S9nA2DOOvdxT3v2S6JjSzmqlZACf/6Htx0lzc 3oWgjd33STA0s8A53ANFL9759MmCY51LM834o0aGWKmQcQtJWTgTGqvvzOTZhbJ3uqlU iI9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Rz9S0GfF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x21si198739pln.224.2019.05.01.16.43.15; Wed, 01 May 2019 16:43:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Rz9S0GfF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726137AbfEAXmF (ORCPT + 99 others); Wed, 1 May 2019 19:42:05 -0400 Received: from mail-it1-f194.google.com ([209.85.166.194]:36585 "EHLO mail-it1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726371AbfEAXl7 (ORCPT ); Wed, 1 May 2019 19:41:59 -0400 Received: by mail-it1-f194.google.com with SMTP id v143so368681itc.1; Wed, 01 May 2019 16:41:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9QwYS9bQr6zIIDqya7O/hmsOjlwL0wV6gZaAMteb584=; b=Rz9S0GfFzc4A8XwKvKPWK6NWM+Fk4CbRC4AjmdPpebD+IyRoyUNo8UtMP3eud+Gmd+ 0LDLFW+zPi79Qhx0IsMKsm6N/r/kMUkAMWk+q9xvzb1Wk9a4oYRKQdTFSxZUxUwgZFgw A8WUnIo4QskgtncNIWH/o/ccSNsfenYWLniVnSfoyeseiBtqm0E+OME3u2fGCkfM74h6 PK43lbzQwsRXWszK0zpVQCoDHr0BgB5n1Hg5aSDJMNN42m/HCJoymqOf8AKzc696Kfcz 7iGli+QVjl1mb+HR7hE3PODcOeDlOS51YsKsw4FasBsgT3THaFPV2DoBI8ACGd6GhPRH dyCA== 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=9QwYS9bQr6zIIDqya7O/hmsOjlwL0wV6gZaAMteb584=; b=VHRydZdE9g09bewRdJN6zDt03UASCshxHCx/M3XBG2N/jzPGYfmN8xoMRGLr6Y1gQ4 7wEQSvxvbGTYrf4dBjEQfWi47cQRjrO8UoDBK7TfWfRnp1BwVCwKAGSVv9j7d8GkcvmE 1Xpxx7DdTerdxs254+zVAxu1MeNIEWvbKUz0++ZtiK6OpGA2YorJG9cjDoBEo+CSQ0Ug QPYor4xMd/bHiFPzCfWdHictgjwZwPh6qtJ7CAkKo6lueLFSB+SWflON07aaw69AHdvk axllYJRyMvhQ8rUA7QizYh708zhJEDcTHies3mIJT8hMnfg5Mf1oMEKk6n+dYMmfiS2V YJgw== X-Gm-Message-State: APjAAAUdu/1MrtMHZ0W7461pXNYwv7YWOO0yOiveGWC4yfTo0kF8Cufr D6JAqOjrTIzr7t6bRQbsDxte20fx X-Received: by 2002:a02:4482:: with SMTP id o124mr305454jaa.121.1556754118389; Wed, 01 May 2019 16:41:58 -0700 (PDT) Received: from localhost.localdomain (ppp94-29-35-107.pppoe.spdop.ru. [94.29.35.107]) by smtp.gmail.com with ESMTPSA id m3sm2392507ion.69.2019.05.01.16.41.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 May 2019 16:41:57 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , MyungJoo Ham , Kyungmin Park , Chanwoo Choi , Tomeu Vizoso Cc: linux-pm@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 07/16] PM / devfreq: tegra: Properly disable interrupts Date: Thu, 2 May 2019 02:38:06 +0300 Message-Id: <20190501233815.32643-8-digetx@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190501233815.32643-1-digetx@gmail.com> References: <20190501233815.32643-1-digetx@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There is no guarantee that interrupt handling isn't running in parallel with tegra_actmon_disable_interrupts(), hence it is necessary to protect DEV_CTRL register accesses and clear IRQ status with ACTMON's IRQ being disabled in the Interrupt Controller in order to ensure that device interrupt is indeed being disabled. Reviewed-by: Chanwoo Choi Signed-off-by: Dmitry Osipenko --- drivers/devfreq/tegra-devfreq.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/drivers/devfreq/tegra-devfreq.c b/drivers/devfreq/tegra-devfreq.c index b65313fe3c2e..ce1eb97a2090 100644 --- a/drivers/devfreq/tegra-devfreq.c +++ b/drivers/devfreq/tegra-devfreq.c @@ -171,6 +171,8 @@ struct tegra_devfreq { struct notifier_block rate_change_nb; struct tegra_devfreq_device devices[ARRAY_SIZE(actmon_device_configs)]; + + int irq; }; struct tegra_actmon_emc_ratio { @@ -417,6 +419,8 @@ static void tegra_actmon_disable_interrupts(struct tegra_devfreq *tegra) u32 val; unsigned int i; + disable_irq(tegra->irq); + for (i = 0; i < ARRAY_SIZE(tegra->devices); i++) { dev = &tegra->devices[i]; @@ -427,9 +431,14 @@ static void tegra_actmon_disable_interrupts(struct tegra_devfreq *tegra) val &= ~ACTMON_DEV_CTRL_CONSECUTIVE_ABOVE_WMARK_EN; device_writel(dev, val, ACTMON_DEV_CTRL); + + device_writel(dev, ACTMON_INTR_STATUS_CLEAR, + ACTMON_DEV_INTR_STATUS); } actmon_write_barrier(tegra); + + enable_irq(tegra->irq); } static void tegra_actmon_configure_device(struct tegra_devfreq *tegra, @@ -604,7 +613,6 @@ static int tegra_devfreq_probe(struct platform_device *pdev) struct resource *res; unsigned int i; unsigned long rate; - int irq; int err; tegra = devm_kzalloc(&pdev->dev, sizeof(*tegra), GFP_KERNEL); @@ -673,15 +681,16 @@ static int tegra_devfreq_probe(struct platform_device *pdev) dev_pm_opp_add(&pdev->dev, rate, 0); } - irq = platform_get_irq(pdev, 0); - if (irq < 0) { - dev_err(&pdev->dev, "Failed to get IRQ: %d\n", irq); - return irq; + tegra->irq = platform_get_irq(pdev, 0); + if (tegra->irq < 0) { + err = tegra->irq; + dev_err(&pdev->dev, "Failed to get IRQ: %d\n", err); + return err; } platform_set_drvdata(pdev, tegra); - err = devm_request_threaded_irq(&pdev->dev, irq, NULL, + err = devm_request_threaded_irq(&pdev->dev, tegra->irq, NULL, actmon_thread_isr, IRQF_ONESHOT, "tegra-devfreq", tegra); if (err) { -- 2.21.0