From patchwork Mon Jun 17 08:46:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 166977 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2582292ilk; Mon, 17 Jun 2019 01:46:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqyPkR5tzcq8+i7Y3jGPz24+a3yK2/E1x2gzO/k0Y7TlMY8K5UNx/liXdDjVt+yV23m4P9/i X-Received: by 2002:a17:90a:2561:: with SMTP id j88mr25208673pje.121.1560761206842; Mon, 17 Jun 2019 01:46:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560761206; cv=none; d=google.com; s=arc-20160816; b=sXQkkNWmIDj31AyctADhT4eCEEV4Fc9z6hrUxWiQTZ/SBXxMzz5LLjYt6Tc+1ikIIz avCLaHbH/ZceRxIooiKFjO82+v/EHm8FdcJNApVlCEs6urhsQsb2h9t4q6i7p1UByCW+ QWPUPI+CD6a0w5t+f7vP+CopGRTyJY89kKhxW+NTyLeb8QNALVdAALzzSq+c//1hQ7T1 J2n+63qRXIC2gtZOwPUP3E8Yp6/6Qdxe8/qMAKaAYNCJLjs0OVCLjRWjH/YXcArW9A5v aG9pkEzqAFKnMkRrvbjW2KR9SXo7Cu9Lt5Lt9m8lfv0t+fRLgOQvsuluaZg1vyGz2C6a P+sw== 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; bh=2GpmxiGAi9MZ2uYPnVRB7goDwTuEZNfhT40Csp3ZMW0=; b=U0VHU/KU5QA5s3P2F/jQ8cIreh6LzX9GuwleUlHBqFeujEGlOmyKre4f63CwFVJum5 tHd7bDQQsZNMl9KDCKFvgyIw1P5pDQrWJ3/agFbbU6Adp6eSLff/HewmE9p/1YK/FETP GtTmp2CKdZstI+orchJn6ZztK7KJOfcpApJU8nDezALZ3+XWifZiTHPSHw0HtvV8aoh5 /UgPyBaX3AyfgyuOC2EwOH5bedVAp0jJJh37Z11csCt4ZHt+YUjJjWIaNkIbmptJYCXM xIf2UmorSfOA9MctraajfdMeiH2XzEi17zBCDH4IOxXz05Fjv0lei8wJYUYJNLjHx5+G 7jug== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k15si614817pga.99.2019.06.17.01.46.46; Mon, 17 Jun 2019 01:46:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727858AbfFQIqp (ORCPT + 3 others); Mon, 17 Jun 2019 04:46:45 -0400 Received: from foss.arm.com ([217.140.110.172]:41826 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727838AbfFQIqp (ORCPT ); Mon, 17 Jun 2019 04:46:45 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 44C6F28; Mon, 17 Jun 2019 01:46:44 -0700 (PDT) Received: from e110176-lin.kfn.arm.com (unknown [10.50.4.178]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 108B53F246; Mon, 17 Jun 2019 01:46:42 -0700 (PDT) From: Gilad Ben-Yossef To: Herbert Xu , "David S. Miller" Cc: Ofir Drang , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/4] crypto: ccree: prevent isr handling in case driver is suspended Date: Mon, 17 Jun 2019 11:46:29 +0300 Message-Id: <20190617084631.23551-4-gilad@benyossef.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190617084631.23551-1-gilad@benyossef.com> References: <20190617084631.23551-1-gilad@benyossef.com> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: Ofir Drang ccree irq may be shared with other devices, in order to prevent ccree isr handling while device maybe suspended we added a check to verify that the device is not suspended. Signed-off-by: Ofir Drang --- drivers/crypto/ccree/cc_driver.c | 3 +++ drivers/crypto/ccree/cc_pm.c | 6 ++++++ drivers/crypto/ccree/cc_pm.h | 7 +++++++ 3 files changed, 16 insertions(+) -- 2.21.0 diff --git a/drivers/crypto/ccree/cc_driver.c b/drivers/crypto/ccree/cc_driver.c index 1e73d32148dd..667bc73d7a00 100644 --- a/drivers/crypto/ccree/cc_driver.c +++ b/drivers/crypto/ccree/cc_driver.c @@ -134,6 +134,9 @@ static irqreturn_t cc_isr(int irq, void *dev_id) u32 imr; /* STAT_OP_TYPE_GENERIC STAT_PHASE_0: Interrupt */ + /* if driver suspended return, probebly shared interrupt */ + if (cc_pm_is_dev_suspended(dev)) + return IRQ_NONE; /* read the interrupt status */ irr = cc_ioread(drvdata, CC_REG(HOST_IRR)); diff --git a/drivers/crypto/ccree/cc_pm.c b/drivers/crypto/ccree/cc_pm.c index 20f7f3d34e27..899a52f05b7a 100644 --- a/drivers/crypto/ccree/cc_pm.c +++ b/drivers/crypto/ccree/cc_pm.c @@ -106,6 +106,12 @@ int cc_pm_put_suspend(struct device *dev) return rc; } +bool cc_pm_is_dev_suspended(struct device *dev) +{ + /* check device state using runtime api */ + return pm_runtime_suspended(dev); +} + int cc_pm_init(struct cc_drvdata *drvdata) { struct device *dev = drvdata_to_dev(drvdata); diff --git a/drivers/crypto/ccree/cc_pm.h b/drivers/crypto/ccree/cc_pm.h index 6190cdba5dad..a7d98a5da2e1 100644 --- a/drivers/crypto/ccree/cc_pm.h +++ b/drivers/crypto/ccree/cc_pm.h @@ -22,6 +22,7 @@ int cc_pm_suspend(struct device *dev); int cc_pm_resume(struct device *dev); int cc_pm_get(struct device *dev); int cc_pm_put_suspend(struct device *dev); +bool cc_pm_is_dev_suspended(struct device *dev); #else @@ -54,6 +55,12 @@ static inline int cc_pm_put_suspend(struct device *dev) return 0; } +static inline bool cc_pm_is_dev_suspended(struct device *dev) +{ + /* if PM not supported device is never suspend */ + return false; +} + #endif #endif /*__POWER_MGR_H__*/