Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932740AbbKXWsT (ORCPT ); Tue, 24 Nov 2015 17:48:19 -0500 Received: from mail-by2on0126.outbound.protection.outlook.com ([207.46.100.126]:51424 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932277AbbKXWsG (ORCPT ); Tue, 24 Nov 2015 17:48:06 -0500 Authentication-Results: spf=permerror (sender IP is 192.88.168.50) smtp.mailfrom=freescale.com; freescale.mail.onmicrosoft.com; dkim=none (message not signed) header.d=none;freescale.mail.onmicrosoft.com; dmarc=none action=none header.from=freescale.com; From: "J. German Rivera" To: , , , CC: , , , , , , , , , , , , , , "J. German Rivera" Subject: [PATCH RESEND v3 04/11] staging: fsl-mc: Added GICv3-ITS support for FSL-MC MSIs Date: Tue, 24 Nov 2015 16:31:17 -0600 Message-ID: <1448404284-22258-5-git-send-email-German.Rivera@freescale.com> X-Mailer: git-send-email 2.3.3 In-Reply-To: <1448404284-22258-1-git-send-email-German.Rivera@freescale.com> References: <1448404284-22258-1-git-send-email-German.Rivera@freescale.com> X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BL2FFO11FD028;1:5C8IFrYrVZp5lhGM9jJCw5oSWIkzj7pPIieVhd5cgvIt+fSZXGWDJfmzDcr1xZJLVzQN4oCVKTF4KuuFxXOZVvgkBIEE/I9duUMp4KHgQ6gPjSpEHulevMt1etgzVXhZt4CXAddairG0LQaVc7TA3k1ik37+rzIycNX1eIZhHNQ32v2itb1N7rlEJsSM1aiMC2Th2ah1Wz2oihZrK4CWlm3sPfV0k4jgBWlt3R4OMukqoy7dtQFdaCmOtNvucXXTQnHKYU7DBCyiuDmTsWsfAdn34VD0YfeaBTTNjGhQTtTmkLB2hAblRZPLeckYTBpM//okZmJcjLe32vDdlhMpMopjbvzfZdYXV3O3kY0XVeZEcgbKd14oYYg4L0uEsc6PbxOIXMbtY7uo611SnyAl9jRwOCyv9KChEzUNRfAV6KufJEsCfAP4kRz6rMfpj1GCe+TXi0IImJoF0lnmpxz1UA== X-Forefront-Antispam-Report: CIP:192.88.168.50;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(2980300002)(448002)(3190300001)(189002)(199003)(19580405001)(19580395003)(189998001)(36756003)(5003940100001)(50986999)(47776003)(107886002)(586003)(5001960100002)(81156007)(5001770100001)(5001920100001)(106466001)(48376002)(87936001)(97736004)(6806005)(50466002)(5007970100001)(11100500001)(5008740100001)(229853001)(104016004)(4001430100002)(76176999)(50226001)(92566002)(2201001)(86362001)(2950100001)(85326001)(77096005)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:CY1PR03MB1487;H:tx30smr01.am.freescale.net;FPR:;SPF:PermError;PTR:InfoDomainNonexistent;MX:1;A:1;LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Exchange-Diagnostics: 1;CY1PR03MB1487;2:Om8E2LE5geHlxX2hspgjTDvQwNMJr9k+9JkzgWl6itNAvH2d0m56PsUmg4taKQq+BHLPdHMu2HeFThxCyKt5afFT90AyfeEUrAfSsTJqX9oiNBo1QbTLAmGQnc00cN3LrKNxKejJNEuOTsAbozZ92A==;3:7FwMzGllFsaUWQwrnmNPCtYIKIaGPoOkx/zttcSbrKHJpd/TdWDo+ioLSOgG5CfgGTZCbo/UtujoOrjlqMXa0cMLqpi6Gkzqv9UbEpGSuit/f7m2+Hd3ecrvHXgG/BYnh4lwm+yS5Ej+pijd5Be/eUQUMquuhblsagPLoO2vRVjWnDD29AFFfr/GktKr0Nanq6fionPuOZhkgTak3RNKqt/SlWxaa08pMBe5z1NdVcs=;25:9BCISfqM6by1lplStQBFN46lS4iaKW9ZHBCFKgP4HQURSnj/dTufpkPd0gbRxRGtzklXaWpmtGA0mSv3/kIf+tXvDgJmNmKBvZBs2ZLVx787JyMDbzf6KB3Nt35ZFeLUsjOv6J75yyBsT+zQlG8T3oDhPpLn3sz34CwD42SgLXDcTJA0sjC0AHLVFpCRf0OfBAMbKpxZor+IcvoqNWj6XIWtPd2l+cpTbL+KCCHg2VChDAcmdAZ0rhj1I5zG/wSjCEvdm4JQRR6oPWBlZ6CZPg== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR03MB1487; X-Microsoft-Exchange-Diagnostics: 1;CY1PR03MB1487;20:l0a/pn3u23ZHa8bPjoxt1TQy3kjbS+Z4+6bBF4PV639ZEw7g6nKuztKuaE85CsSdNsiRyDPPC9hDP69fN4nwXrGJNB9PV6oorF8lChXqSo2z/p/csu/UFEN0GQsBAf2IDkne7vf0xsUKlALLO1Ipe5lVu1unqq1t55slCcNyigSMx761y2u3Gi1oFhmxLIBZHy5acaFPSn4qoRm5IUqhayuOY9JlvuRtDw2vaAFyVcvFLQgOgbQ251MZBiaY+qK6iLyqjQlvjXBEkCnvnPpFyLLXw5io70rvYH3IdGo4pGRbSYMY8zjAdZklNbO6+iOd83GV5XEnQgelWiy5ihnfs2g3jSIkf3q/os64BHTiP20=;4:uL85oJUX0PLtZUvfaMr8WDNiHg0thSl9uIOcREu8g95y5JKQwSNfZFfRC4lgX4bRQaoMeO8BHXhctHj6UPw5FvvxiMEg9UVqiapgo5kRivf4RGUUIjFCDWOSszIN4TJ4P9O/KHSFUienB9j9m4ziOpqAbgWtqXTTdGhKkcEPNQY1Vf2iGjOrSWSyVxYnPKE61lDNskj63nkk8SEQG5+OWTAJycHjo0SlshAHDy+kQESSY/8FOSfiCrS/IwktSral2HP7hypVj+0wHVZ7zVBMZEOe1xt63K28mbKy98aLzV22Ssf/upZ8pm3aJS9RClfIll2XvGxR+h6hgoTmWGF3X7icvEoALeCM+qcb900QKI6wYVSjosKjz45UVhZw6Ai7GsrKkFJjAc8URE2FVsS+XRrlRP/JLQddKtR/9r8lRymjDt2jma80KMGFNKV/BJTc X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(101931422205132); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(520078)(5005006)(8121501046)(3002001)(10201501046);SRVR:CY1PR03MB1487;BCL:0;PCL:0;RULEID:;SRVR:CY1PR03MB1487; X-Forefront-PRVS: 0770F75EA9 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;CY1PR03MB1487;23:JDwQagZI/WTpXHJY81VcCdfUeWpg31zMnkpxPHMqe?= =?us-ascii?Q?7TSesKFRbxSchAAu8OBFmugt05aS/ppVnpwOlzuCgzXpz3ykSlEdcr4rvurd?= =?us-ascii?Q?fXmRQjQFLBy16rvzjh6bdu/G6SA5XvvDdft2rYQdpLAGdrdPnkYc/J8v4BbV?= =?us-ascii?Q?9gBnHNNI1sI89bXa/laN19IVhN36OM3+lO1nGKLdrZe8H2AIru+wMc2H+X3J?= =?us-ascii?Q?MoeJUEvgR1HqElpGQ5mF9l7ELQRqepnYPYE3hjPKNT4ttBlcEMFgpVOjrDTB?= =?us-ascii?Q?MuAHn4Z8JKTUd1g2NCzGK4XTywujZpV+5VGcAI2eXhWzIJai9PawAfq6JZbN?= =?us-ascii?Q?Oe98+Ed7SYZEpgNfRUtMq/9MmTRCqtu5ieLEwA7fmMZTLoh1Tu51DPk3fopa?= =?us-ascii?Q?3qDaabvlYiiVSS7JtgZG6ex2JMRpPSw1WJoBKi02pFCdKGDV5OLSeyZ03BZY?= =?us-ascii?Q?p+IjmA7910INLAGsAG5U7NgmcLoUOaoUo0lufyIzGapmcuq66wAjVNfKHF86?= =?us-ascii?Q?mzAYZXxrGDa1E1W4RUNj1OofnPX3gV7Ns31LftzBJnhrJOgtmhSlBLao2eK0?= =?us-ascii?Q?5zLw449xgHQZtop+iBNbo7tKNvVyHbpeRX0fwx6eZvWIRRTM8IvxlPvjIPTs?= =?us-ascii?Q?6RtDZyy5rakad/EkM2Ow7tv4B//xQWYRLpcG4vEvNf4i/pcG7kwz1wGqqfst?= =?us-ascii?Q?1Iv74Qr1hcljwqONX70MQg8Jdq/s8vVJ3PWLPb9G83wznQecO6u9SLkmxKo8?= =?us-ascii?Q?A0l+dhGkArTFT7zomBRjoEY4kYsmwzeUbQAnD+6qf5TiTpqV/5rGlIekA2Y8?= =?us-ascii?Q?1lrsDjAP+PByUzWhdUz7QTPfh1fitnEHxRvFoBBq0WQSLePBrCFPPzIosRCt?= =?us-ascii?Q?5iz4dzCK+W2mV6mV+2feUAuZaiW94FNCfKt5ETtDZn86HZ5FezmR2mwxCk2O?= =?us-ascii?Q?0eazY2iYICniCk5L++gU8faFQTSMA5YZs1JuVjJ8v1tUXWyXwRoHwcZpsJAi?= =?us-ascii?Q?cv/7tCm1d3Sx2TD2+RDhuCXjYdUsf3sdM13jJ9iSAIEI73XY2+DQ7spo9lIq?= =?us-ascii?Q?xFng+Csddafe1ZCcd28iwgsC+GNP9oGXXg7CPpfO41fafs9iQ=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1;CY1PR03MB1487;5:8i7y2IlWPtnGD+UU87huVz16EEnYT19JfoEmRWklr0rcOJc7Ln4QZrnlPFkHz7LF8NHFk0/KD5zyNchdErS8bheaO7JkaTKgWUUWLVhF0RhIdlq5o2e67Qy9W9ijD0xZ9bRwWvxTKsGbVEW3ZwEnXg==;24:4/Rvci6j5bC/6A3APhpU3jUUoyaLUZcSd5YRjVxjfWmmJy/DiFDdyqX3C+d2jliLlXMiOt9QkQYz4ilsZ1FkhooXg9X9/7MKG9p0hapYRxc= X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Nov 2015 22:48:02.9952 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d;Ip=[192.88.168.50];Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR03MB1487 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5458 Lines: 181 Added platform-specific MSI support layer for FSL-MC devices. Signed-off-by: J. German Rivera --- CHANGE HISTORY Changes in v3: none Changes in v2: none drivers/staging/fsl-mc/bus/Makefile | 1 + .../staging/fsl-mc/bus/irq-gic-v3-its-fsl-mc-msi.c | 127 +++++++++++++++++++++ drivers/staging/fsl-mc/include/mc-private.h | 4 + 3 files changed, 132 insertions(+) create mode 100644 drivers/staging/fsl-mc/bus/irq-gic-v3-its-fsl-mc-msi.c diff --git a/drivers/staging/fsl-mc/bus/Makefile b/drivers/staging/fsl-mc/bus/Makefile index a5f2ba4..e731517 100644 --- a/drivers/staging/fsl-mc/bus/Makefile +++ b/drivers/staging/fsl-mc/bus/Makefile @@ -14,5 +14,6 @@ mc-bus-driver-objs := mc-bus.o \ dprc-driver.o \ mc-allocator.o \ mc-msi.o \ + irq-gic-v3-its-fsl-mc-msi.o \ dpmcp.o \ dpbp.o diff --git a/drivers/staging/fsl-mc/bus/irq-gic-v3-its-fsl-mc-msi.c b/drivers/staging/fsl-mc/bus/irq-gic-v3-its-fsl-mc-msi.c new file mode 100644 index 0000000..5319afa --- /dev/null +++ b/drivers/staging/fsl-mc/bus/irq-gic-v3-its-fsl-mc-msi.c @@ -0,0 +1,127 @@ +/* + * Freescale Management Complex (MC) bus driver MSI support + * + * Copyright (C) 2015 Freescale Semiconductor, Inc. + * Author: German Rivera + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + +#include "../include/mc-private.h" +#include +#include +#include +#include +#include +#include +#include +#include "../include/mc-sys.h" +#include "dprc-cmd.h" + +static struct irq_chip its_msi_irq_chip = { + .name = "fsl-mc-bus-msi", + .irq_mask = irq_chip_mask_parent, + .irq_unmask = irq_chip_unmask_parent, + .irq_eoi = irq_chip_eoi_parent, + .irq_set_affinity = msi_domain_set_affinity +}; + +static int its_fsl_mc_msi_prepare(struct irq_domain *msi_domain, + struct device *dev, + int nvec, msi_alloc_info_t *info) +{ + u32 its_dev_id; + struct fsl_mc_device *mc_bus_dev = to_fsl_mc_device(dev); + struct msi_domain_info *msi_info; + + if (WARN_ON(dev->bus != &fsl_mc_bus_type)) + return -EINVAL; + + if (WARN_ON(!(mc_bus_dev->flags & FSL_MC_IS_DPRC))) + return -EINVAL; + + /* + * Set the device Id to be passed to the GIC-ITS: + * + * NOTE: This device id corresponds to the IOMMU stream ID + * associated with the DPRC object (ICID). + */ + its_dev_id = mc_bus_dev->icid; + info->scratchpad[0].ul = its_dev_id; + msi_info = msi_get_domain_info(msi_domain->parent); + return msi_info->ops->msi_prepare(msi_domain->parent, dev, nvec, info); +} + +static struct msi_domain_ops its_fsl_mc_msi_ops = { + .msi_prepare = its_fsl_mc_msi_prepare, +}; + +static struct msi_domain_info its_fsl_mc_msi_domain_info = { + .flags = (MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS), + .ops = &its_fsl_mc_msi_ops, + .chip = &its_msi_irq_chip, +}; + +static const struct of_device_id its_device_id[] = { + { .compatible = "arm,gic-v3-its", }, + {}, +}; + +int __init its_fsl_mc_msi_init(void) +{ + struct device_node *np; + struct irq_domain *parent; + struct irq_domain *mc_msi_domain; + + for (np = of_find_matching_node(NULL, its_device_id); np; + np = of_find_matching_node(np, its_device_id)) { + if (!of_property_read_bool(np, "msi-controller")) + continue; + + parent = irq_find_matching_host(np, DOMAIN_BUS_NEXUS); + if (!parent || !msi_get_domain_info(parent)) { + pr_err("%s: unable to locate ITS domain\n", + np->full_name); + continue; + } + + mc_msi_domain = + fsl_mc_msi_create_irq_domain(of_node_to_fwnode(np), + &its_fsl_mc_msi_domain_info, + parent); + if (!mc_msi_domain) { + pr_err("%s: unable to create fsl-mc domain\n", + np->full_name); + continue; + } + + WARN_ON(mc_msi_domain->host_data != + &its_fsl_mc_msi_domain_info); + + pr_info("fsl-mc MSI: %s domain created\n", np->full_name); + } + + return 0; +} + +void its_fsl_mc_msi_cleanup(void) +{ + struct device_node *np; + + for (np = of_find_matching_node(NULL, its_device_id); np; + np = of_find_matching_node(np, its_device_id)) { + struct irq_domain *mc_msi_domain = + irq_find_matching_host(np, DOMAIN_BUS_FSL_MC_MSI); + + if (!of_property_read_bool(np, "msi-controller")) + continue; + + mc_msi_domain = + irq_find_matching_host(np, DOMAIN_BUS_FSL_MC_MSI); + if (mc_msi_domain && + mc_msi_domain->host_data == &its_fsl_mc_msi_domain_info) + irq_domain_remove(mc_msi_domain); + } +} diff --git a/drivers/staging/fsl-mc/include/mc-private.h b/drivers/staging/fsl-mc/include/mc-private.h index 0b294d4..3423993 100644 --- a/drivers/staging/fsl-mc/include/mc-private.h +++ b/drivers/staging/fsl-mc/include/mc-private.h @@ -133,4 +133,8 @@ int fsl_mc_msi_domain_alloc_irqs(struct device *dev, void fsl_mc_msi_domain_free_irqs(struct device *dev); +int __init its_fsl_mc_msi_init(void); + +void its_fsl_mc_msi_cleanup(void); + #endif /* _FSL_MC_PRIVATE_H_ */ -- 2.3.3 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/