Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp3966867imb; Wed, 6 Mar 2019 01:51:50 -0800 (PST) X-Google-Smtp-Source: APXvYqyI8TP5FWKbPev0/a4tJ+c8851n9LPEdYoW8aD/G1Afhyze/I8ylL6Lm9u3/e6eBAR/7l00 X-Received: by 2002:a17:902:834b:: with SMTP id z11mr6105894pln.257.1551865910565; Wed, 06 Mar 2019 01:51:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551865910; cv=none; d=google.com; s=arc-20160816; b=LMi3KLaRdk6jZVjA/xKVb0q964dhcuVJXjhgMr9EhcyKq+iSxLEkRUD6Lrn9dgUN60 G1fo6hbw0xs3SiIugoQHsV2ikC/Rgg8A0pQjOj/DIV9uHt+beMkiNBAf1lPfxgU99xgi krWOrQ9fvQFn1d5Ep4ZKU5Qrnxmqy6Ruo8kMOHHWy7ZdINmCinC8Y47HM3TRXKc16se5 OUaz2seqtb+rADtFoUm5jSZ07yOzP+r2VZ06FF5wLuPVbUZasUbvmYUAZWhy8zZOvFpv 4Daia4/RILcEl9u6AeVnNsiViN6J+TK0alMPjXnNiqYWlnLCUwDNolagweAB1tdzjsa8 P1Dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=eKvvplRLQSYzjDLI3gt9oFgDv8/pXIwBLecUrwPGzKk=; b=Q/ZluyoPewk6cR9U3eq+omGQ5vD4o+w14tifMjLQJpWfdNF9b628wRfMT1PDsJj8kA QUEs6bmcS0hgqId//WoDaOCIBofcXQOJfUbIxRH4NJmMuS6Uxc1tXmwErNnTtfeG5eKZ h+Kx3yz2NgymqSofwT3p0JXPFyy2jrzuZnA4WlsqAUYLJ8vo8vy9gPoURTkktEparEAz 0b9DmmfJhAZ1RMbmgWAqfXJH24eiCSk1+tfAg7AJR2iUYVh58iExPzgQ9F1ug6Z2Yzud wnBvaTW4fiyi4a8mnCj8ZzWOSJM0IucjwokVq1KiwJQNqjy1VWRtQk939evHgz9JskUE V+Ig== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p190si1069490pga.42.2019.03.06.01.51.33; Wed, 06 Mar 2019 01:51:50 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729884AbfCFJuq (ORCPT + 99 others); Wed, 6 Mar 2019 04:50:46 -0500 Received: from mailgw01.mediatek.com ([210.61.82.183]:44119 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1729862AbfCFJuo (ORCPT ); Wed, 6 Mar 2019 04:50:44 -0500 X-UUID: a3cb263c18dc49c489bb796399e04336-20190306 X-UUID: a3cb263c18dc49c489bb796399e04336-20190306 Received: from mtkcas06.mediatek.inc [(172.21.101.30)] by mailgw01.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 402421878; Wed, 06 Mar 2019 17:50:39 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs08n1.mediatek.inc (172.21.101.55) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Wed, 6 Mar 2019 17:50:38 +0800 Received: from mtkslt302.mediatek.inc (10.21.14.115) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Wed, 6 Mar 2019 17:50:38 +0800 From: Bibby Hsieh To: Jassi Brar , Matthias Brugger , Rob Herring , CK HU CC: Daniel Kurtz , Sascha Hauer , , , , , , Sascha Hauer , Philipp Zabel , Nicolas Boichat , Bibby Hsieh , YT Shen , Daoyuan Huang , Jiaguang Zhang , Dennis-YC Hsieh , Houlong Wei , , , Frederic Chen Subject: [PATCH v2 05/10] soc: mediatek: cmdq: move the CMDQ_IRQ_MASK into cmdq driver data Date: Wed, 6 Mar 2019 17:50:30 +0800 Message-ID: <1551865835-50974-6-git-send-email-bibby.hsieh@mediatek.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1551865835-50974-1-git-send-email-bibby.hsieh@mediatek.com> References: <1551865835-50974-1-git-send-email-bibby.hsieh@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The interrupt mask and thread number has positive correlation, so we move the CMDQ_IRQ_MASK into cmdq driver data and calculate it by thread number. Signed-off-by: Bibby Hsieh --- drivers/mailbox/mtk-cmdq-mailbox.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/mailbox/mtk-cmdq-mailbox.c b/drivers/mailbox/mtk-cmdq-mailbox.c index 909eb23..6db1e2d 100644 --- a/drivers/mailbox/mtk-cmdq-mailbox.c +++ b/drivers/mailbox/mtk-cmdq-mailbox.c @@ -17,7 +17,6 @@ #include #define CMDQ_OP_CODE_MASK (0xff << CMDQ_OP_CODE_SHIFT) -#define CMDQ_IRQ_MASK 0xffff #define CMDQ_NUM_CMD(t) (t->cmd_buf_size / CMDQ_INST_SIZE) #define CMDQ_CURR_IRQ_STATUS 0x10 @@ -71,6 +70,7 @@ struct cmdq { void __iomem *base; u32 irq; u32 thread_nr; + u32 irq_mask; struct cmdq_thread *thread; struct clk *clock; bool suspended; @@ -284,11 +284,11 @@ static irqreturn_t cmdq_irq_handler(int irq, void *dev) unsigned long irq_status, flags = 0L; int bit; - irq_status = readl(cmdq->base + CMDQ_CURR_IRQ_STATUS) & CMDQ_IRQ_MASK; - if (!(irq_status ^ CMDQ_IRQ_MASK)) + irq_status = readl(cmdq->base + CMDQ_CURR_IRQ_STATUS) & cmdq->irq_mask; + if (!(irq_status ^ cmdq->irq_mask)) return IRQ_NONE; - for_each_clear_bit(bit, &irq_status, fls(CMDQ_IRQ_MASK)) { + for_each_clear_bit(bit, &irq_status, cmdq->thread_nr) { struct cmdq_thread *thread = &cmdq->thread[bit]; spin_lock_irqsave(&thread->chan->lock, flags); @@ -472,6 +472,9 @@ static int cmdq_probe(struct platform_device *pdev) dev_err(dev, "failed to get irq\n"); return -EINVAL; } + + cmdq->thread_nr = (u32)(unsigned long)of_device_get_match_data(dev); + cmdq->irq_mask = GENMASK(cmdq->thread_nr - 1, 0); err = devm_request_irq(dev, cmdq->irq, cmdq_irq_handler, IRQF_SHARED, "mtk_cmdq", cmdq); if (err < 0) { @@ -488,7 +491,6 @@ static int cmdq_probe(struct platform_device *pdev) return PTR_ERR(cmdq->clock); } - cmdq->thread_nr = (u32)(unsigned long)of_device_get_match_data(dev); cmdq->mbox.dev = dev; cmdq->mbox.chans = devm_kcalloc(dev, cmdq->thread_nr, sizeof(*cmdq->mbox.chans), GFP_KERNEL); -- 1.9.1