Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966095AbbKGBqg (ORCPT ); Fri, 6 Nov 2015 20:46:36 -0500 Received: from mail-by2on0103.outbound.protection.outlook.com ([207.46.100.103]:61120 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1758040AbbKGBqZ (ORCPT ); Fri, 6 Nov 2015 20:46:25 -0500 Authentication-Results: spf=fail (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 v3 04/11] staging: fsl-mc: Added GICv3-ITS support for FSL-MC MSIs Date: Fri, 6 Nov 2015 19:30:20 -0600 Message-ID: <1446859827-6927-5-git-send-email-German.Rivera@freescale.com> X-Mailer: git-send-email 2.3.3 In-Reply-To: <1446859827-6927-1-git-send-email-German.Rivera@freescale.com> References: <1446859827-6927-1-git-send-email-German.Rivera@freescale.com> X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BY2FFO11FD044;1:xaMWArraVUFO/jGCx/bf1P8oK59v/kjE3bz5cPvQ1fr/XAuFEYQ2yTzd7xAGM/sqIgRA4U0D0dlOz3Ri7daiPxgEqgTr+VkZmHwjSV+qQhyLSXnOgs1Aztncg1pCwWp1PpvVmqvorhzsMaCCrhZYGmuqrEDDHvy84Z7WW3FX90AGnlwgj7VOR4SKf7d8fd1oJICCqMesU7BJ7AnAx/11e2aotOOMqn7G0EgQ9+Dbm56j3z1BNQfFxINEsVsQiozE/1MN89CjLubL1V3+Epm9xE5NAqOf2c5OL0pqw6QW358Od3N2CC1GwkBoo5QcrswkaopClT04dRTT4Csi7jCFpWyvV8/rneSrX/rS6f8BTCtP7HqeANFAactxDrm8N1phdOVlI3pFUA58egf5KI5LBQ== X-Forefront-Antispam-Report: CIP:192.88.168.50;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(2980300002)(1109001)(1110001)(339900001)(199003)(189002)(47776003)(2950100001)(5003940100001)(50466002)(5007970100001)(50226001)(87936001)(5001960100002)(5008740100001)(4001430100002)(50986999)(107886002)(85426001)(76176999)(104016004)(48376002)(6806005)(86362001)(19580405001)(19580395003)(77096005)(5001770100001)(2201001)(106466001)(189998001)(92566002)(81156007)(11100500001)(105606002)(36756003)(229853001)(97736004);DIR:OUT;SFP:1102;SCL:1;SRVR:DM2PR03MB512;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;A:1;MX:1;LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Exchange-Diagnostics: 1;DM2PR03MB512;2:CgJ1kgsGfqiI1NVwaf7miCXdYzouIdEjJOGp3jK+XMViVTfmPDettb7wJdA1YL3mg02Tl0wbWvWJVgrCLRedI0z88g0tf9W4wHWT9MptIbL8pJfolxCFYD3guCNRMN9Xg6ZolvDPT+LaSYzZQZr+m7DROY+xhbsX9/wXZoufYXI=;3:kME+lO9mTwP6ZP+POZpZdMNC+sAAGa+DYLpNqnJ4IZ5S6iVcReGyTxdDvwjYh+eQh7lTDPK/3EEjgyz1KeLvy5mwkOOgSx6AZhwhnFR5iO9TYnPJq4hrnPqNv3LCMj6NgOyKaZlCw3FQZhSnUpezMBrnDU/9XyJCnkW4wqW4VqkZhyGXCz8FodwqrYVdrGXP/buZF9kXcooR14D1bqKTViANeTDBcqAykHh01sZ3ivI=;25:HXCNg61HxOX7+BL5qH2ccWSWQmD8xX4pxmMryJ7CLE4Fq5wxExnsqwOsTQZ7M+dgzFAKRn1yfqem475xnzqKlEPfdeMqAGh0KCgKjRShfLppoIM1K+oST+xoxpQC7+XD6E5kf6PPXUsACtj/v4xWBHb1DaUVojPTeG0WkiNUydPAF8NB/YNM8py2tzQZxs34NjcdEwZ3DJGd2Hjg0IcawFNaRTh8AOoDEimks58B8BT8v4BD3+VHz7c981F+tyI5Nh+en6VuIpyD3U1wA4u1Iw== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DM2PR03MB512; X-Microsoft-Exchange-Diagnostics: 1;DM2PR03MB512;20:dopWtq4aMbHk2jep+ZZ9h1L+m0JZG74DQJ0IXWTCxttrbUuWUrNA0nlT5++wANrYj+PDnbhxz6q2UfYNFxVn4x5duPNWh5Y2qjfNt02EGLkTCabOOGLIaUxr4bJWWp6LUAF4rkj2d7ONy+vmRhDA4W8X1yjiYtm/oyNVBva0nSvqXJIEkvR/CkEyXie0WZX9NPDq+J2mUsPXY+jnRcQDOhedRKjSGqz0Kgr3p9gNkgn4OxXw3FkQQBvz9frV9hR5TGZ+ihhSpaR9+gRWOBSmhZYRDuLVxEdGif7hhVCDihofw4wQyszWZ2hTH3tRZwmkjI5I38z91lLLT+unK4ybYWaPrtoR+wdzNnAyv8hwLu8=;4:28MU8RYOluVi51cLRvs7lADZEWIw0NYtFFYYNnL+ASULIpkoEzAazej5nQL69iSGRwZ/8Ye/ZU4i2Ll+r3XswE6vzsDVzNo0IPRImD/7ON9HRzMKn42d6FTN7ZxOonrzLcRMP06lDxvdxbQ/E9BGSc7w18/c3m0UTDspr3Q5GTmwyLE85wlDTSHugl2ChLQqVI3fH3RkOJBvEWKJvffaF5axLx7nVatG0Q3dLUBjo5xaQP+ZxcIXrq1PYqP3FwJ5FI/lhsQzPC6Bk39LpStE33EFT2NPiRBZOHNr5U5qPDvCzgCNYCU1+G9ut51Mnn1PFO+RAagJdEtK1iCqLFzFYUEimsh+ff/aHfP4rO6Fv/yLVjtZwWeHb1zmf7MUcjcG X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(101931422205132); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(5005006)(520078)(8121501046)(10201501046)(3002001);SRVR:DM2PR03MB512;BCL:0;PCL:0;RULEID:;SRVR:DM2PR03MB512; X-Forefront-PRVS: 0753EA505A X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;DM2PR03MB512;23:KxFnoiYN3sKi058t7z+BXbUSHprXzJsLvLeXrBE0tU?= =?us-ascii?Q?uv3IGFAd3vosIxWRz4VamvXsNE6Sut/gktrFN0Q6++tZ3E9UXbc+a2ppQ6iz?= =?us-ascii?Q?pPNnRSjdpBTW72o2d0JAFlcMVNQ4uy5PP3stiJKAFWDncOUalEEleZBT8YqW?= =?us-ascii?Q?mfHhkw4gqWE9jKIBxIr76i8WL+qdepDajLuDc1B5tBuhlwvGXfTT7Y2Yyj2s?= =?us-ascii?Q?Gg3CwGosekRLc4XeOdB8gqp585p8CtPFZda1ZkRrYos09rjw8vsCPHVqSaTx?= =?us-ascii?Q?2NJuNrTACtI3InEkodt4CF/dcQqb3PGFtuhQeeMTqqlfRHeeBNyc7p+koomJ?= =?us-ascii?Q?mcO9YR6tf0jnQyV9bVGGX7esgJ1tpZGZPVIkz+UtEJlh+9s/hPUzR0Nf24O0?= =?us-ascii?Q?zPkofoCy8rqcv08Y7VkuCcHWHevNKyZ8tD8PebxMjfTHZ60QcsrSfghSGvw9?= =?us-ascii?Q?/NlFPS0WoUWCT9clA9QcWq2/DRhT9L2hvL0cQDu5q0JC1YB4uIxpPyPuneZr?= =?us-ascii?Q?NqRqxEh1EGdexQo8RdJaG8mbINNnAVRSkqkqShZMP3hqvm6D4NAht6kGMo7G?= =?us-ascii?Q?bnOHUXzQkbH/mrv4VjJmv+X1ytOuYO4bHA7+GRthOJnogDDG8BJKwFD+a6FP?= =?us-ascii?Q?PzqvhITje9iorezvCBPV5ou48HkLKo+x6NziAy9b+0xcCP3Q6D0WW6gunnDJ?= =?us-ascii?Q?fj160RcqDZUF10FHsRYd8JWolZcT6VOG6dlrC20fSdFe5Y/6fL7f76JaV6p3?= =?us-ascii?Q?4vWjcuBzQ+i8+PW8OBRR2WTqDAQn3F71VU1Eghm9kZANwaOaw45saD5RFaCH?= =?us-ascii?Q?HiHLsz86LxMuuW4dF7hjmBrCUOGaePQ3BE/3oUHM0lxF0temUMw7VXOLypXz?= =?us-ascii?Q?kV1bWhDxST7RwcKWpYyuZa9/C3khPUVeGMKGvR6LAGVB0gr9dIPMtJ04+xn1?= =?us-ascii?Q?BeonQNCjikcE9J+Zb/wWJRuLPgVrQX9kAGA16GMIIzyp+emuHvE3cHAFUf/Q?= =?us-ascii?Q?F1149U5Ux5EDYKXMTSAB5fRr54cAuWLPwf9klftlr+lCVKMEO10DzInquqrz?= =?us-ascii?Q?47Bs4n92QGxVkEAPaezyYi7d0z?= X-Microsoft-Exchange-Diagnostics: 1;DM2PR03MB512;5:GaLUNq32VdEAJofDiUG18Mt8bU016SyxOGqwfn7IdrpdL+Lt/v6KCMQuxKn3WxQFG9SbQDpqkE4ro9LHaRx3Hsw3QcCl1IoC6Tarn7nxD0lVLbq4opI4FMvdf3CVh++Nat0OjbF7b6IhJi+5ZdEBcg==;24:OV1QYvrtvDzf7z+jpc4xY1dOeVDoNtSdRZmptPGsrlxbX8AthUVpuOSDViL284yb6UHgMkL58P7v8c5CzLL+c10AcEKZSDvOYpBMf3/wmog=;20:CZQwqA3d/dbRIvwp8NDvydkOxJTHp1M95p++GrYnsajtFhflW8+oVDXCwVcjNopAnx4Abv9ZyKSBN7k+ME3xZA== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2015 01:46:20.9078 (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: DM2PR03MB512 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5459 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 3dabd003..f2504bc 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/