Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752844AbcL0JZa (ORCPT ); Tue, 27 Dec 2016 04:25:30 -0500 Received: from mail-bn3nam01on0082.outbound.protection.outlook.com ([104.47.33.82]:51584 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752149AbcL0JZX (ORCPT ); Tue, 27 Dec 2016 04:25:23 -0500 X-Greylist: delayed 842 seconds by postgrey-1.27 at vger.kernel.org; Tue, 27 Dec 2016 04:25:23 EST 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; From: Minghuan Lian To: , , CC: Marc Zyngier , Rob Herring , Jason Cooper , Roy Zang , Mingkai Hu , Stuart Yoder , Yang-Leo Li , Scott Wood , Minghuan Lian Subject: [PATCH 9/9] irqchip/ls-scfg-msi: add MSI affinity support Date: Tue, 27 Dec 2016 17:13:05 +0800 Message-ID: <1482829985-24421-9-git-send-email-Minghuan.Lian@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1482829985-24421-1-git-send-email-Minghuan.Lian@nxp.com> References: <1482829985-24421-1-git-send-email-Minghuan.Lian@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131273034793991125;(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)(39450400003)(39840400002)(39410400002)(39860400002)(39400400002)(39380400002)(39850400002)(2980300002)(1109001)(1110001)(339900001)(199003)(189002)(5001770100001)(68736007)(626004)(85426001)(104016004)(92566002)(105606002)(5660300001)(2201001)(86362001)(97736004)(6666003)(47776003)(2950100002)(189998001)(8656002)(230783001)(356003)(8936002)(2906002)(50466002)(305945005)(77096006)(81156014)(81166006)(4326007)(38730400001)(50986999)(76176999)(48376002)(106466001)(8676002)(36756003)(50226002)(7416002)(5003940100001)(7059030)(2101003);DIR:OUT;SFP:1101;SCL:1;SRVR:SN1PR0301MB1583;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BL2FFO11FD031;1:WVTwEpcEvOHYRWgG3Clw6okpU2Ofus5jndPMCZKYUaKsiBSbbNivAp2idA3EdfNkrJC6MZji6NUIgrUatgoqfbHYg6ZyxEt1QvjFNrbaF/p5XmCH0cyJt+EpOaDA/GLI0lr/IOMwcsSlWkHId1pGHUFdO3DVlSEU8ChBBejriU3vH5Jou5X6MqJDo/Mm/bl6/KeZ0vQmnMwIJrH0SK2/O7ghrFp01AuMuyfdSG2UTQd5KwRxTasSNPOSfUfZrOXQGA85SFpaKpFzoeFhBLs9Tans5Wv8K2I2bNcCFj5AvhqgUbJV5J8nXcVMwbjXih9rGXvsNTLo3AM0X/bMGUkQSq24C1vYbn+1n1/idH8/xxqJs5g4JM8Gqf707s7y83NSOy4J/zZoDO6BAVccUVpIde2xSWWMnMNSYBm43ouZyyOdcVcjV8seC11ZB6axwcraCbLa43lEYz+o/0oiBZwVTdvD6Pz3aXIH4jLj5+Iw1bQ5VsSBKxv6GzZqBTlPqUbCuzEQTWan5kc7Em7YqEF7xKwNUBKnoPeZN0kF65F1RNo1TWvR9ELHkcQmT6HEfQPHZnwjx4blQhFN7aCEWdFODpXhufcJiCyUhHCuMBysLNGICca/dTn0RHFkaXGE08SWN46InHr84G0EMUg8IvLDx0nUTPvPCsGEX6clvhXWLp4xSY7NJLrExSWBkT3PAow7qcuV6bLFVFDDYWZt9AuiPR9HwhqEdWzAkogGxV0K1p2wSnnTED0TyDE1TzfpRZ3e MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: b52204e0-f6c9-4069-5a74-08d42e3851f0 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:SN1PR0301MB1583; X-Microsoft-Exchange-Diagnostics: 1;SN1PR0301MB1583;3:+UmVMlkyjKtIqWiB9zif62HLs+CvDm2EKq/dicxPcU9JEEMaOHdjbOzWIKbTMNSXfuz/RBIvkEOLX1gk3zLL/AJJScg1abEt3O1qigBRKPM+u9m2TYQ69oxfJFXAfNXnOfkhacYbGOTip/BZH9fytYojOh4UYL08cTxXWgc6VaV+s1NFCHwiLMWJfJDVYHHnXXATd83QSmAQhIMwBk93dfKPMbNDvQzeLJGvsT49wqlA/xtXxOCTohwpfVYWWJdvNVcG73g0Or3abXvnN/l+i4YU6yvsoGvot2ltv3jAqpddXeS3tgPpqrLpCqAn3vIlJ17gTu+ng9zRt3F30o6y/w9EqOhyvM9QWio0UTDp0BrIuAkiwbdizuIscMi20cVN;25:FDhaN8neqJa708DHmBX7vdZ/5ITCg4SdO/IPn7VzBSK/AHLvTCVK0u+dRIWCThOedui7f9UdkS8VdUbssJ+TutrIIURcpHoNSiNXda5abG+/4wiuaBmp5iMA6tYVGbEXXgHjcuqB4ixbL1gjCeOijucsbGNKbGhkNs3el4CUog/CRZPwXe3cz55r4xDu3wrHXPsbyg9TQ68i3tAZqM1WQzkLIlR12uAI5dqksBQ7BdbAMJRytkVa+17hynE/df1YDs0l85VqqiuwMhf9OuXKFmqYmV2DbM7zwvaXT91z846CbF+QHpq0eeU1g0rX3M2a79imfn+DAV0kUFprV+uewTGq89ahxBM/wjmJk0GpIJ84YS8BqCNwV0Qjz64XoY/rmw/VT8XMegLFW5mvVl2Gr2zzo/XmyMP1KsE+kr+DetuLDf6qrisap9YMuTRlbVwGfWucEysbDT4L5mrHfMR9cQ== X-Microsoft-Exchange-Diagnostics: 1;SN1PR0301MB1583;31:yZRpkK6xTQ1Md5HMokUxdD7VAmVTfRqd78011IUOmnCW0OnRZs54UR9mxRTggzoqU5shYOnZauNljFWBDcSSyzMZc1J888518jHZaVLOfZmyhjRSDaytF+xJnzSpY2xjTa+GEalhTmE39YRolHIa1wD/uKxi7igeeHjZ8ZO2R+GXnRvpu//eCJ6pfuXnBn1ewG3GRlEFZOmEd//btTldAtgYtcnBiGJYAe8QT97VSnkgGUcTKMnxCPXkWbyOjieXcINLdiAkSeU+Aa/aIocJqonT+EqekWmwAcSEQABctak= 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)(13017025)(13015025)(13018025)(13023025)(13024025)(8121501046)(5005006)(3002001)(10201501046)(6055026)(6096035)(20161123565025)(20161123563025)(20161123559025)(20161123556025)(20161123561025);SRVR:SN1PR0301MB1583;BCL:0;PCL:0;RULEID:(400006);SRVR:SN1PR0301MB1583; X-Microsoft-Exchange-Diagnostics: 1;SN1PR0301MB1583;4:ABWtFBYEeXbJVPL4/mKpmG+RbhSsmNR5AsjSn4s1PEZ8Hpn+LffB9rMryEEAPFAfX7CqoCWXBfQXJysES5ifonof1ul57qinr8pDvG3ILRcroWCjgAWWJ6rGDnOuYu+cgjFY9zhuYOkRdTkvx/m+AWMYLZ7+fWCZxQ9sWRM5SZIMAMVTJ7gtsefUl3MLdx5YhzlE8qGySexFBQ4dmOj5Pa73oGu7mWAw3lMX9z8175fABRWexDKSiz0owQFk6bLYUzTZJ6IWjjVahCZfDyEUl9Tv2qmkTIS9LFYCzy1Tv1FUOEPzwA2qaT3Tzo758U57CCG+6/E/K4Xh2eN24+PdMpq4cY3ZrOgzPODgMLyppD6DX3A3Kl2M7yLA/0QDW14T8d3grEp18daxWDvPXptsTudYnrmeu6Ggjc5YN4/klESZCXEJsmDDVHnTvY/XOp+l91aBow4bRoG65KdSORF4SCHMB6A0itDs/l3/QvOAzGQw6bUDRJVb3KpjPy1jVf/GypEI2sPPVC8797MoXWx0xEGG/UxwgMf7yEBB7DwfqTDygdTPPIzznnk1OQELGXbVO71Of1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rasp5eIQ55KePNABvkVLhu0iN/2qkUP0HifQS?= =?us-ascii?Q?Gj3VxVowg2qro5dnb7oEcZi/oqwYFV2Kn1PNLhWmnhcNqNTg4BvtIVGZREvY?= =?us-ascii?Q?EWPCNYHLfg9okqL7wYRMoEc9IhsYODMDto0U9tzrE59AhGqXaXPaqDseUof2?= =?us-ascii?Q?fjrUrbTVanH1bq5SQgalYUOoNxU+/5AytzhqVtWaoS26qYltu6yd23s4DYRo?= =?us-ascii?Q?sN2b8SH/VMY13ijL3yCZAxsutA0RwKna8FuVcPZzFvYOL1t8wAfCp/Q25maf?= =?us-ascii?Q?BZbJaUreV/WZBBrySRf9sQ7OimeF2ZP5yPnXqI/9tlzAHlnC8ldL3TyQLOBQ?= =?us-ascii?Q?uDu5zKZHYCDeBy937vjz1F9ibHGyD88tkK30v6Fo48zni2zDES5KobqQQ/Li?= =?us-ascii?Q?Y/BoNk2mKBKzuzqwrFAukruYWeQstPs5bBKhoHlwf0PPXM7Yp95kznVi9niz?= =?us-ascii?Q?hgMZYVDXA2s4XoMmJEtUW4e+g7cfGohEcAoBMyCdRZOsKN861+B0MPmahj+Y?= =?us-ascii?Q?HRrdfDrsut3FJ/+sIRfsb9lWi1s66R6cg0qJ77o6AU1QM+SF+Q0IH0kVz/AQ?= =?us-ascii?Q?LkvyMOKEyc1YWQhNHFPFoF98bXl4nE/vNnGOqKTWM7R7zgBbEWghdoD/FjdW?= =?us-ascii?Q?H5Jxqv0QhRBjkMXlc55IQMGQ=3D?= X-Microsoft-Exchange-Diagnostics: 1;SN1PR0301MB1583;6:yL1j9bqmVfOq4tmm14ocljttaCrr7aH24XN/UwjDhrKexoTX465t30QhdmOp0XXNxNiDVIKFzFG3tkQLUlVb39dI6nL0knpc84vYNT92fsiaFWxFIy8tn0pharJD6UZ3Uzo5kzPY8zARHKAUdOJ5F3xbqtbql+FWSnoyPbABwE3EjLPrUqiYpvDcfFc912ik1385GEzMyeFIPEFVB/cSENA90mHhlrg84OjmXSSTH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Exchange-CrossTenant-OriginalArrivalTime: 27 Dec 2016 09:11:19.1495 (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: SN1PR0301MB1583 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4319 Lines: 143 For LS1046a and LS1043a v1.1, the MSI controller has 4 MSIRs and 4 CPUs. A GIC SPI interrupt of MSIR can be associated with a CPU. When changing MSI interrupt affinity, this MSI will be moved to the corresponding MSIR and MSI message data will be changed according to MSIR. when requesting a MSI, the bits of all 4 MSIR will be reserved. The parameter 'msi_affinity_flag' is provide to change this mode. "lsmsi=no-affinity" will disable affinity, all MSI can only be associated with CPU 0. Signed-off-by: Minghuan Lian --- drivers/irqchip/irq-ls-scfg-msi.c | 75 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 70 insertions(+), 5 deletions(-) diff --git a/drivers/irqchip/irq-ls-scfg-msi.c b/drivers/irqchip/irq-ls-scfg-msi.c index dc19569..753fe39 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,43 @@ 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) { + u32 msir_index; + + msir_index = cpumask_first(data->common->affinity); + if (msir_index >= msi_data->msir_num) + msir_index = 0; + + msg->data |= msir_index; + } } 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 +203,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 +266,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; @@ -316,6 +370,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); -- 1.9.1