Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3060614ybi; Mon, 29 Jul 2019 00:04:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqyBkPH5GAWRdonSk9kik4wn/mtw03jFQT+K/QTwIkMUHgkxJSmcTaZ2gGc7hl7RmZOHTMqF X-Received: by 2002:a17:902:86:: with SMTP id a6mr21832621pla.244.1564383898074; Mon, 29 Jul 2019 00:04:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564383898; cv=none; d=google.com; s=arc-20160816; b=IoqQAWxEQyaJfQB6ennyQ1PEjTAbcIyYhgZOwGJ32I+lMtieaszx0uCkROiWYXkR7r V9SwY1EjHEDgy4gZpSldSTP/NYjyd0o3FeYXLM6zlGp1R6AywkxLivSuxkqYwtXDDjIY iPVsZPyOWAOVm4xicHCxHA6vHljJCS0OmquQisacz88nPKG98lrrKxzDcTSKkHTSvgTY vZwiBY1ATa1L09m/GojBo6Ieer9lAeAZCb5hQmgQwhfz4TpvxSVKqBTdmXMJGLl2Zy1t yBJ6sXXDlBaFe+01mgt11Xm1IeslmXqo6IV9iW1apuhmGvgKeT6agHPjsl/6Ngp8tqpa f8lw== 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=0/HgJPemt+s3RcRghDl+n0Bx1TZkBGd24228tyAY9zk=; b=JxeAu1CdO7gMeTephk5oxr1RgCcX0jQmeVifgJPQAMfnXaegXTkOC+wWFj0AxsNaQP 6HlGrk10VDzEcVUynmtar+WdHBqMnxnXGQDEXBIyruWmEOxmQ0TFdB7WVEvteGVHvjST 2Pi9qexQJAVTzEpidD+78OtPj4vDwlyrS1RHknfR2vEs0lr84x0z/tzWmmsL8yEJOPAz QMaDEwpK/Q/fxrezo/JLqxx2HNaWpDVLbT1fY/4AxogIF3EXGxSncLyXi6huFoiv/P6n YY5meehZqc+RekiAx804Xuno+4wjARNUHwWPMbU3b9ylNiqNuNESXD5KuAbHSxa2T1SD sPxw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h11si51277025pjb.98.2019.07.29.00.04.43; Mon, 29 Jul 2019 00:04:58 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727126AbfG2HBU (ORCPT + 99 others); Mon, 29 Jul 2019 03:01:20 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:16223 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726988AbfG2HBS (ORCPT ); Mon, 29 Jul 2019 03:01:18 -0400 X-UUID: 935bb13a6cb349368239cb782fcc4ff6-20190729 X-UUID: 935bb13a6cb349368239cb782fcc4ff6-20190729 Received: from mtkcas08.mediatek.inc [(172.21.101.126)] by mailgw02.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0707 with TLS) with ESMTP id 339190299; Mon, 29 Jul 2019 15:01:09 +0800 Received: from mtkcas09.mediatek.inc (172.21.101.178) by mtkmbs08n1.mediatek.inc (172.21.101.55) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Mon, 29 Jul 2019 15:01:08 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas09.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Mon, 29 Jul 2019 15:01:09 +0800 From: Bibby Hsieh To: Jassi Brar , Matthias Brugger , Rob Herring , CK HU CC: Daniel Kurtz , Sascha Hauer , , , , , , Sascha Hauer , Philipp Zabel , Nicolas Boichat , YT Shen , Daoyuan Huang , Jiaguang Zhang , Dennis-YC Hsieh , Houlong Wei , , Bibby Hsieh Subject: [PATCH v11 04/12] mailbox: mediatek: cmdq: move the CMDQ_IRQ_MASK into cmdq driver data Date: Mon, 29 Jul 2019 15:00:58 +0800 Message-ID: <20190729070106.9332-5-bibby.hsieh@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20190729070106.9332-1-bibby.hsieh@mediatek.com> References: <20190729070106.9332-1-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 Reviewed-by: CK Hu --- 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 00d5219094e5..8fddd26288e8 100644 --- a/drivers/mailbox/mtk-cmdq-mailbox.c +++ b/drivers/mailbox/mtk-cmdq-mailbox.c @@ -18,7 +18,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 @@ -72,6 +71,7 @@ struct cmdq { void __iomem *base; u32 irq; u32 thread_nr; + u32 irq_mask; struct cmdq_thread *thread; struct clk *clock; bool suspended; @@ -285,11 +285,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); @@ -473,6 +473,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) { @@ -489,7 +492,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); -- 2.18.0