From patchwork Tue Jan 17 09:32:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "M.h. Lian" X-Patchwork-Id: 9520305 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6735B60244 for ; Tue, 17 Jan 2017 09:32:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5867A284FA for ; Tue, 17 Jan 2017 09:32:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4C06D28516; Tue, 17 Jan 2017 09:32:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9EBF5284FA for ; Tue, 17 Jan 2017 09:32:58 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cTQ8N-0005JO-78; Tue, 17 Jan 2017 09:32:55 +0000 Received: from mail-sn1nam02on0082.outbound.protection.outlook.com ([104.47.36.82] helo=NAM02-SN1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cTQ6o-0002FT-7V for linux-arm-kernel@lists.infradead.org; Tue, 17 Jan 2017 09:31:25 +0000 Received: from CY1PR03CA0042.namprd03.prod.outlook.com (10.174.128.52) by CY1PR0301MB0748.namprd03.prod.outlook.com (10.160.159.154) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.845.12; Tue, 17 Jan 2017 09:30:56 +0000 Received: from BL2FFO11OLC006.protection.gbl (2a01:111:f400:7c09::131) by CY1PR03CA0042.outlook.office365.com (2603:10b6:600::52) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.845.12 via Frontend Transport; Tue, 17 Jan 2017 09:30:56 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none; nxp.com; dmarc=fail action=none header.from=nxp.com; nxp.com; dkim=none (message not signed) header.d=none; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BL2FFO11OLC006.mail.protection.outlook.com (10.173.160.95) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.803.8 via Frontend Transport; Tue, 17 Jan 2017 09:30:56 +0000 Received: from lmh.ap.freescale.net (lmh.ap.freescale.net [10.193.20.69]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id v0H9UGHF018177; Tue, 17 Jan 2017 02:30:52 -0700 From: Minghuan Lian To: , , Subject: [PATCH v3 9/9] irqchip/ls-scfg-msi: add MSI affinity support Date: Tue, 17 Jan 2017 17:32:43 +0800 Message-ID: <1484645563-29877-10-git-send-email-Minghuan.Lian@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1484645563-29877-1-git-send-email-Minghuan.Lian@nxp.com> References: <1484645563-29877-1-git-send-email-Minghuan.Lian@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131291190565644933; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(336005)(7916002)(39840400002)(39860400002)(39450400003)(39400400002)(39410400002)(39380400002)(39850400002)(2980300002)(1109001)(1110001)(339900001)(189002)(199003)(50466002)(81166006)(48376002)(8936002)(8676002)(2950100002)(305945005)(86362001)(36756003)(81156014)(5660300001)(7416002)(97736004)(189998001)(30001)(6666003)(5001770100001)(2906002)(50226002)(2201001)(4326007)(85426001)(77096006)(5003940100001)(38730400001)(105606002)(50986999)(92566002)(8656002)(68736007)(104016004)(230783001)(106466001)(356003)(47776003)(76176999)(626004)(54906002)(2101003); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR0301MB0748; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11OLC006; 1:zbKKZK0t4AG+AyRrvTMJQET7J2ERGIY/49rZqc201NUAhvKPuvjD/weOVDKRYB3VCGNEFDdE+rx6VsEpk1ITZ/Vjb2wd1aQLLs/ktDoIRmJ5aL+RFB5ByWz15lfj2uPUUMVocqrKbrhR6lZbssHG7IrYnlRjlrsClkWT9poUdRxx1Wf6nM2AIllURxL/84fhWFMVKAwrwzE0h2EYdHbib7gmpF93rS4U1y4Zmrn3rh6EfskO6DVdoAR+7K7QmetzLS4uwmxOewIenZplqLxcI8Qct6ST2v4soh5rgluCqiTXqYgDIc2dx38jOJ3+P8e9xMx7PpW6+YEu/s0n1QrC6gqXGqLASPKRdQ8noY5kVGFrjnbeIqRjK4V8S9mLW2vw3c5nQfwTw7rxRvBOq+j7hfO6AQs5M8qjjQ5w6cGSWUHdHQ19vQ55v1BGWfmYH3Ew8RQNChYUeuDS5Bns4gSxyNgV7zvc1p4nvOt0Yj6I+bUZNCeXFBaONdGzS7KFyNkofx//tmRPrWXmU1jreLd6K5xzayMoB3BNSWjEPMfcYD1ELtPsZrrV4gctMz7/keN/1d6t4JuEFZHOqToJTySL2SL9WG4Njwt7hSfSVnjia5s9m0l0ZLV2B+CxgB0cmtv2bV3rJ5GeVyzpskvZ4YvnoB5hKBuYBRaRKkSFcuCCyLRLMYuoNRLSDwwhgGwT+FZx/KFURusvi2c7nJtqGBWC1JIag0QdB3xzNVMf6OQAEkM= MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 68b0ba4d-36f0-4e6e-aa85-08d43ebb8a44 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:CY1PR0301MB0748; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB0748; 3:TaLFILh6ptoXqLYEUzuYPOgVDxWBxoWmszqrBts259JxXutsXCKUQCRG5qpIe++Nk8yZQ0TAE3dVhc8lpMvV73S5hY3tJYiIUaebbVgg9RNJu2g04imQJiQiB3BMGBCOpO/amp4UkaowV800WgLJ6SO2v16wIp2LDFUPFKu8gPxLgL5qgWPqlfH3EJdn0UHmHsFNVNtiIN47XRdcTlbffzvTA/w0eu/rGs8h3e+GoQoVStARxWzBr5Hg5s3At5YLJef3mVTd1/aNWyzLQwWDcdWRtReuqet0bE+Cj02xvFT4UDCpFe2G8ZqQAvgN3FpPQUHuC8WCk3WPJogI+UOSJ9wUIYkSUHy+yqSjNOSl9h/cQ3X91RZEREOFiqJFhav0; 25:IilspvzeR96s1feGyhoVuC5fi8lX96VZVQpmJsXRXjdsRXzzrwGjKM+48bPzIE1kSeMg+MRlb0s8I51bEqDOVCGdlMYWCXT396ciqhemG/h0isF72DYf0RwC3k3t9rYyl9fbD5PvLJLKrWTtWgTt64BZMm2k8QIO7y2joLmien/LaZctk26bQnExX+Y1EZWvBGdYoN4ji9tWpB9NwVrC95oCZjYFyifaTDcvrwhanWe9yLlJLm7hCHbp9z4ZE1UJllETS6fIUb0cXcc5pLGjZM1eT36rHf1AkY6lqKFqAWhLNx3no/eP8qP2icBBSTbEwApY4ddq3FxZl1qYyT5Ix3R9A5HmrRI2JmKFVFTjOM4rsHB6KboS7uIgBC7M2+uYu40MTKkYNesdq2AfowR5244s7aCgqyM/4FuN1kDR+scQD0fxrQaSY60YWxCpQxzRdevOcBwo3EBGF3tLQHgyxA== X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB0748; 31:qeC4l1DGhnIO0GLiIeENns97qOJ1VywuPvcfftLcHu/JoI3w0NzkzUP5zAKsCuV5leqFGMPLP+JQxzunIFlrS5ODIb980hHFfG/Qjcx3bUkIj2uw08QLT+PVKGrKfyW4AJFSdnkdyMwu7v8FxcVh1WNCjsLPFpgqze3QxDEKbxWctiwz3u8oTvTcvx4lSc5q59O9SGcP/xiviK2FcjSycPZg9eim8mem3gxccs9kdi9KBPt9zxlL7fbX8mIeX+AjsOOzoVvfTgO0+iHXCzGxuw08SkiLR1egfYHNVrsmJfI= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095060)(601004)(2401047)(8121501046)(5005006)(13024025)(13015025)(13023025)(13018025)(13017025)(10201501046)(3002001)(6055026)(6096035)(20161123561025)(20161123556025)(20161123563025)(20161123559025)(20161123565025); SRVR:CY1PR0301MB0748; BCL:0; PCL:0; RULEID:(400006); SRVR:CY1PR0301MB0748; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB0748; 4:OBv0X47vQ2UrGr9CKoTwmprv+Dz7TtWzUEOGXXNfz35BT0hL7fFKEa7qYAdwejAiy7fWQ/rpd1TNtv7kkjYGWfSvTIq8bjzLEympy8N+XicwCIdQ06rJ9xu3xx8EIJVmJU2W8if1K/HqKfYQvvKcsapXRSIQ9p8rN6k11N3uU995y7UsxI28cvLAW9Wxg7ml2fthPeqA3iQ5qxYI3eTTi5lfFmPTBc1AN+8boiUEgQK7gH09k9EK/k0EK0KnjlsZmZiBjItKjiYFqekgsKpZ0oZ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TG/NpKo6AuPHQ8BhTtDFYHhkIiEJ14Kh4TJz3IOXVf6598BjXrhXhk9dVj4rESIvAUNm32p3GyiQJEMYvIA43YTg01iOOSFF6d9cztEhyP16U2+49mNXbO/84SDO2afzSPN8yWUD/0vAxY/luFfIM6ydQFtp+k418gQtkkvdlhCDCIzt2rsElxJYSjb0TsKlG3bL3JQ6LBMSl9AFRXhCLJ8+MqRPH+DKqRW3YnvRayU5X7sjpod3Djj+XGr1nJ4F+t6vN6vAB9ZSzjASk9V6KcuhVw4bfh8f+XJS7I6KcPIhtMi9BCSdVdwaxPMg3mhKGgm+8h77g== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jan 2017 09:30:56.3460 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0301MB0748 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170117_013118_675153_D7B8D35A X-CRM114-Status: GOOD ( 22.43 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Rob Herring , Jason Cooper , Roy Zang , Marc Zyngier , Stuart Yoder , Yang-Leo Li , Minghuan Lian , Scott Wood , Mingkai Hu Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP For LS1046a and LS1043a v1.1, the MSI controller has 4 MSIRs and 4 GIC SPI interrupts which can be associated with different Core. So we can support affinity to improve the performance. The MSI message data is a byte for Layerscape MSI. 7 6 5 4 3 2 1 0 | - | IBS | SRS | SRS bit0-1 is to select a MSIR which is associated with a CPU. IBS bit2-6 of ls1046, bit2-4 of ls1043a v1.1 is to select bit of the MSIR. With affinity, only bits of MSIR0(srs=0 cpu0) are available. All other bits of the MSIR1-3(cpu1-3) are reserved. The MSI hwirq always equals bit index of the MSIR0. When changing affinity, MSI message data will be appended corresponding SRS then MSI will be moved to the corresponding core. But in affinity mode, there is only 8 MSI interrupts for a controller of LS1043a v1.1. It cannot meet the requirement of the some PCIe devices such as 4 ports Ethernet card. In contrast, without affinity, all MSIRs can be used for core 0, the MSI interrupts can up to 32. So the parameter is added to control affinity mode. "lsmsi=no-affinity" will disable affinity and increase MSI interrupt number. Signed-off-by: Minghuan Lian --- v3-v2: - 1. update the description - 2. remove unnecessary msir_index checking v2-v1: - None drivers/irqchip/irq-ls-scfg-msi.c | 68 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 63 insertions(+), 5 deletions(-) diff --git a/drivers/irqchip/irq-ls-scfg-msi.c b/drivers/irqchip/irq-ls-scfg-msi.c index 8d57a59..119f4ef 100644 --- a/drivers/irqchip/irq-ls-scfg-msi.c +++ b/drivers/irqchip/irq-ls-scfg-msi.c @@ -40,6 +40,7 @@ struct ls_scfg_msir { unsigned int gic_irq; unsigned int bit_start; unsigned int bit_end; + unsigned int srs; /* Shared interrupt register select */ void __iomem *reg; }; @@ -70,6 +71,19 @@ struct ls_scfg_msi { .chip = &ls_scfg_msi_irq_chip, }; +static int msi_affinity_flag = 1; + +static int __init early_parse_ls_scfg_msi(char *p) +{ + if (p && strncmp(p, "no-affinity", 11) == 0) + msi_affinity_flag = 0; + else + msi_affinity_flag = 1; + + return 0; +} +early_param("lsmsi", early_parse_ls_scfg_msi); + static void ls_scfg_msi_compose_msg(struct irq_data *data, struct msi_msg *msg) { struct ls_scfg_msi *msi_data = irq_data_get_irq_chip_data(data); @@ -77,12 +91,36 @@ static void ls_scfg_msi_compose_msg(struct irq_data *data, struct msi_msg *msg) msg->address_hi = upper_32_bits(msi_data->msiir_addr); msg->address_lo = lower_32_bits(msi_data->msiir_addr); msg->data = data->hwirq; + + if (msi_affinity_flag) + msg->data |= cpumask_first(data->common->affinity); } static int ls_scfg_msi_set_affinity(struct irq_data *irq_data, const struct cpumask *mask, bool force) { - return -EINVAL; + struct ls_scfg_msi *msi_data = irq_data_get_irq_chip_data(irq_data); + u32 cpu; + + if (!msi_affinity_flag) + return -EINVAL; + + if (!force) + cpu = cpumask_any_and(mask, cpu_online_mask); + else + cpu = cpumask_first(mask); + + if (cpu >= msi_data->msir_num) + return -EINVAL; + + if (msi_data->msir[cpu].gic_irq <= 0) { + pr_warn("cannot bind the irq to cpu%d\n", cpu); + return -EINVAL; + } + + cpumask_copy(irq_data->common->affinity, mask); + + return IRQ_SET_MASK_OK; } static struct irq_chip ls_scfg_msi_parent_chip = { @@ -158,7 +196,7 @@ static void ls_scfg_msi_irq_handler(struct irq_desc *desc) for_each_set_bit_from(pos, &val, size) { hwirq = ((msir->bit_end - pos) << msi_data->cfg->ibs_shift) | - msir->index; + msir->srs; virq = irq_find_mapping(msi_data->parent, hwirq); if (virq) generic_handle_irq(virq); @@ -221,10 +259,19 @@ static int ls_scfg_msi_setup_hwirq(struct ls_scfg_msi *msi_data, int index) ls_scfg_msi_irq_handler, msir); + if (msi_affinity_flag) { + /* Associate MSIR interrupt to the cpu */ + irq_set_affinity(msir->gic_irq, get_cpu_mask(index)); + msir->srs = 0; /* This value is determined by the CPU */ + } else + msir->srs = index; + /* Release the hwirqs corresponding to this MSIR */ - for (i = 0; i < msi_data->cfg->msir_irqs; i++) { - hwirq = i << msi_data->cfg->ibs_shift | msir->index; - bitmap_clear(msi_data->used, hwirq, 1); + if (!msi_affinity_flag || msir->index == 0) { + for (i = 0; i < msi_data->cfg->msir_irqs; i++) { + hwirq = i << msi_data->cfg->ibs_shift | msir->index; + bitmap_clear(msi_data->used, hwirq, 1); + } } return 0; @@ -320,6 +367,17 @@ static int ls_scfg_msi_probe(struct platform_device *pdev) bitmap_set(msi_data->used, 0, msi_data->irqs_num); msi_data->msir_num = of_irq_count(pdev->dev.of_node); + + if (msi_affinity_flag) { + u32 cpu_num; + + cpu_num = num_possible_cpus(); + if (msi_data->msir_num >= cpu_num) + msi_data->msir_num = cpu_num; + else + msi_affinity_flag = 0; + } + msi_data->msir = devm_kcalloc(&pdev->dev, msi_data->msir_num, sizeof(*msi_data->msir), GFP_KERNEL);