Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753595AbbLKS3j (ORCPT ); Fri, 11 Dec 2015 13:29:39 -0500 Received: from mail-by2on0136.outbound.protection.outlook.com ([207.46.100.136]:34656 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750951AbbLKS1M (ORCPT ); Fri, 11 Dec 2015 13:27:12 -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 v4 04/11] staging: fsl-mc: Added GICv3-ITS support for FSL-MC MSIs Date: Fri, 11 Dec 2015 12:09:42 -0600 Message-ID: <1449857389-2506-5-git-send-email-German.Rivera@freescale.com> X-Mailer: git-send-email 2.3.3 In-Reply-To: <1449857389-2506-1-git-send-email-German.Rivera@freescale.com> References: <1449857389-2506-1-git-send-email-German.Rivera@freescale.com> X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BN1AFFO11FD043;1:i/JpTL/YLGqZX6MLuB5IzshEBSdM+zBE7SIMjToKF0WywLqZuBOOKUYot7QHj49BB8h5zo3aD78Px5hERdzSn7mBPvrSMMIncnPb2KdH/FSfZAvvFg/6lTalhywh4Ci+L+wue3vP1p1I0w6MeG7hKYvB+3LwmGNOOdMbpa4fui0CZZd6SzoN0vznYz0s0Bwf4oe+xa6Fnuyxg63j2MWSEN+pOcOyNoJTQ/9eN26QjHShOibNnYpt0EQjnftwZ3CS03Gvgb0hWmBTZGzRdYkXXy2vWdXYjUJxImLFzfOt2x6fBWJ7E/rdACp7JHsq1PhpZqQNQtY0Ueci6tn1Fy5cH9jcLjueb2harQZDhCF2dlbXqzFGPpVrOgG2TX2LWoexOYDS/fzwi8WJMDkVW22QwG9z8Pp8FCnIfoFQJDMS+Oz58Noct00pNRsL2tQq+hcF X-Forefront-Antispam-Report: CIP:192.88.168.50;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(2980300002)(448002)(189002)(199003)(6806005)(85326001)(1220700001)(5008740100001)(87936001)(586003)(11100500001)(50226001)(4001430100002)(1096002)(104016004)(2201001)(86362001)(106466001)(189998001)(77096005)(50986999)(92566002)(50466002)(97736004)(5001770100001)(5003940100001)(107886002)(76176999)(5001960100002)(229853001)(48376002)(47776003)(19580395003)(81156007)(36756003)(2950100001)(19580405001);DIR:OUT;SFP:1102;SCL:1;SRVR:BLUPR03MB1476;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;BLUPR03MB1476;2:pLc9wFj0EVURbvBumZRsb0nOHKj80yUflt/mJ8rFPD0DNTJ3+dJTS5kv4teMo7B6Shh43fqlBsZVgfHy/tsb0RJL5/jt+VScYoWl396MaCebwFdaCK7eWn4qHACNxXFntpzV/v3euckfUJR+Lz0glA==;3:Ndo8M2B2Zelt5bK8PdoU1Sfcz1FSnm9igQq3jD6oSNkkqE5H21ZBuB/IMMHWsiSdqvNt+b2t8gK3a8kTSQJudIklEw4RErbqyciTp2yq1xgVy0TBTQW1NfvBIFFNfk/fkI2M74Diq50YJdR5WVm4C2ANk4ox6EowNLTAn05w8VzVA6HWgeMkIVBBtP8RMKCXyGwKDmG5HYcLZBHrS94B0GVKmQkmKM79XLkDMUqzpRI=;25:09HjDYg3IFoJ4WWSMJosKgAmmXFfVKtQuRTgGFu8e6iofs680QONzjq/6PBOmk/EMVy/JTEOZlgSwnhNCpcMdj5msw1SRooC8URjOTr2xNXBSX2PAfVtOJobWWMOy7jWBNUU3pqDOVUepX7pweUa2wUHnl3dfsNQlQ7O1dxuW3UjtGNmwbQt+5bZX12jrI8DFqjVWhWAhoQm80p+b4dfYb8DCpjVAuYsnPFWMJbaqeLlvAc1C+PcAMpXih687MQVWjgcRFiiu1JYJtQSD/44RA== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR03MB1476; X-Microsoft-Exchange-Diagnostics: 1;BLUPR03MB1476;20:1nzl6C99vcvBwGpqDapWFW/ZxpgA3t+bOuszvNKF4gFq16mhMmfEmjSbWFbJS1psv91nqkdhLZ5k7sIHxf/S1/wQwHWrmPrwYopOClJ8CEoI/SSMGSTUmX4YdMm0f9YDzGmSh5yzENLy14ea53I9kQsemxmdMeYxCGCbaVAKOqnq6EXn2LW4kL+KtpqzbRiYf6hgphv6oZ6c4qvb1gIMKIiUHBIRB2eVnMFlvOTm3KtKtrjVMapkAUmyz04bRetjXBFEdMhesr/p2KHOi4kxBV6RwbM+RBcBd4ZCBz8LTiX4+Wf4UvB9MXvEdQ71CUZSwyIplN+uFvajslJnLFDg1J1kVVSLMK9B8U6L4FtSZgQ=;4:60a+g9xC16OjOnv7k60ty6B+PevLZ/2zRaO7vsHMtyiYjzG1GlycqCAVdKiRr2+2u2HepGcI9tZMygqv7suKmpB5QVqEFobRtXj7Wth8z+8W7/5KiJLE8+D7gr+0qauyV8N08JwP76zqQGcKgk4idA71/22mJmf8sGlKGTFn9vGmqk7yAgu7xRJr4OjkBUV3uSNCaeVLP5lzaWf6kCkohGVEnAnhgwhIbnjdHcPilWIEajFV3hqRQR+bWizavVSDwjjODTvueTb7MCMm/IiKcE8mWnZ19VZ97bypUtMyhU30znQNqBBZ0ak41zrtNmy6htCY3P9yAtyLWztbC3Qz/22jOAs4Fcx0DCc11TabbdRGQUNmLYQ8zZYyrS5kwus2X8kzh5xvpb0JnKS4VGcstzSpSDE/QX6N0H47kuM8AUqROKd4UWqXE54YbNJ/dHq8 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)(8121501046)(5005006)(10201501046)(3002001);SRVR:BLUPR03MB1476;BCL:0;PCL:0;RULEID:;SRVR:BLUPR03MB1476; X-Forefront-PRVS: 0787459938 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BLUPR03MB1476;23:fc/hMRSPe9bTlLrckfQ0HT/cZI6Nlr7kls72hYfli?= =?us-ascii?Q?87mfnHqpD4qEsZ+nbAs/9lORupWLDZ70Bc1Ln7mIeHqLrRoLQOwwy4eQRX1z?= =?us-ascii?Q?NzRst+Vl30nyjZZn1gl+r2AZtBfheYxMiKnRAvvWvL8IrMGhsx5AJhj53wUh?= =?us-ascii?Q?pHRP85znRLq2omdasfFsAZhtWO/YatnKVjJGVZ1xS7/aTTyNK/wxNmZw/dXr?= =?us-ascii?Q?JEDgAku4UGifFkDIheo66EgziMCcPBQWgTVESD6vJBqQxoC9hKXpSLg0OGvF?= =?us-ascii?Q?f3cDdgIrw/kXRFHKMZW7m4yCMSc15ZvaduDITfPP6J2jGclzj0HYaQMgBFOZ?= =?us-ascii?Q?61TdIldjr0nofURpOAa20g/z2JWF2RDzK2y2jBfLnU1HwLU8btHjAlBg+XVT?= =?us-ascii?Q?IFr02V2QTIBALd5xfaxZu0kV456Wpy0SysHg7y1bt9bk1FBsp0S459ok/F24?= =?us-ascii?Q?5oaqb94GtHIvVdk+A7ltd6vcQCHmapNAB80+2cfoEZh42uOBV9R6kIMVJp2L?= =?us-ascii?Q?Y5wsYdt+W6pe3hgPUp/dsC4P0sgpDCamEjg+q2cLP5k0uxVOmm3R7Yb43Bgf?= =?us-ascii?Q?OSBCQ0+h7NZVlszzPyVV4oz31qlxtLC6zmhtlNSCmFYl09uLmhabF8IvihU9?= =?us-ascii?Q?IpmB9rfEHzJD5B0OMDh72aAgJwbh9pbz3sCp62HFp0y0EM3W4352duSiIRCr?= =?us-ascii?Q?23MNNBZMhLULC2BUYH6OK+he/5Crtk2gyyHFb1VcEVNZv1PnszcE66kNU/of?= =?us-ascii?Q?zPxb4NNHajNc+zQWtKbegGm3Hkasy9pKzK1LzR6RlQXaQRjL1i2Z+0r72e5T?= =?us-ascii?Q?FHC9J/LF9OlagDb/CTcyQlaP0004P+6MfEwIFJP8AdP1UKHcYkpHC2MLbRXo?= =?us-ascii?Q?oOAcEN01SZ+xWUjiXXhHHF3WniEdIp3hnmB0TyUMDBcV4GM5oSNVjoZ7l8Rb?= =?us-ascii?Q?gcOsFpej+khHcAvv82hw8+cYM8DJva9y7+XdvtCk7xeRosrGS9cklTSxiu0H?= =?us-ascii?Q?5aUjdlWv+koFRAD+h4znq7IsuPlvzqubgQM6tbm7UYvbQ=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1;BLUPR03MB1476;5:KO7TZZTh5D0/DuozsYfD2TEFwsr7c1CDvElhfzVgI1WA64UtlFCnfZgybefa4GKryqqVVbaS1Sf7hGKBpRXEQu3hn4LRS45/YK9jxEGw4mZxqRrR/LwTKeYL3Z2v6ZHhUSuYWh11JoODCkzffGLC8A==;24:4vmGh8t8Efrxno9pGhRmw5c0Bh5AoB9Ai38jM7ZJN+fYkCf3ti+VsqIyf7i5njAfcoF7f3pf5eEyehosBl7wMK1z+w+1yFyYFpHo/9T4MWY= X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2015 18:27:08.8174 (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: BLUPR03MB1476 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5667 Lines: 187 Added platform-specific MSI support layer for FSL-MC devices. Signed-off-by: J. German Rivera --- CHANGE HISTORY Changes in v4: - Addressed comments from Marc Zyngier: * Moved bus type check earlier in its_fsl_mc_msi_prepare() * Removed its_dev_id variable * Changed some assignments to keep both sides on the same line 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..4e8e822 --- /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) +{ + struct fsl_mc_device *mc_bus_dev; + struct msi_domain_info *msi_info; + + if (WARN_ON(dev->bus != &fsl_mc_bus_type)) + return -EINVAL; + + mc_bus_dev = to_fsl_mc_device(dev); + 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). + */ + info->scratchpad[0].ul = mc_bus_dev->icid; + 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 36b418c..28c8d32 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/