Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752224AbbEGOwH (ORCPT ); Thu, 7 May 2015 10:52:07 -0400 Received: from mail-bn1bn0101.outbound.protection.outlook.com ([157.56.110.101]:10048 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751121AbbEGOwD (ORCPT ); Thu, 7 May 2015 10:52:03 -0400 Authentication-Results: freescale.com; dkim=none (message not signed) header.d=none; Message-ID: <554B7BF7.8030901@freescale.com> Date: Thu, 7 May 2015 09:51:35 -0500 From: German Rivera User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Dan Carpenter CC: , , , , , , , , , , , , Subject: Re: [PATCH v2 1/7] staging: fsl-mc: MC bus IRQ support References: <1430947708-10521-1-git-send-email-German.Rivera@freescale.com> <1430947708-10521-2-git-send-email-German.Rivera@freescale.com> <20150507130330.GI14154@mwanda> In-Reply-To: <20150507130330.GI14154@mwanda> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [192.88.168.49] X-ClientProxiedBy: BLUPR01CA033.prod.exchangelabs.com (25.160.23.23) To BN3PR0301MB1299.namprd03.prod.outlook.com (25.161.210.154) X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN3PR0301MB1299; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(3002001);SRVR:BN3PR0301MB1299;BCL:0;PCL:0;RULEID:;SRVR:BN3PR0301MB1299; X-Forefront-PRVS: 056929CBB8 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(6009001)(6049001)(51704005)(377454003)(24454002)(479174004)(23746002)(47776003)(189998001)(65806001)(77096005)(66066001)(4001350100001)(62966003)(77156002)(122386002)(42186005)(40100003)(59896002)(46102003)(83506001)(87976001)(86362001)(36756003)(5001960100002)(107886002)(110136002)(92566002)(2950100001)(33656002)(5001920100001)(50466002)(76176999)(87266999)(50986999)(54356999)(4001430100001);DIR:OUT;SFP:1102;SCL:1;SRVR:BN3PR0301MB1299;H:[10.214.82.210];FPR:;SPF:None;MLV:sfv;LANG:en; X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2015 14:52:00.2135 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR0301MB1299 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5216 Lines: 168 On 05/07/2015 08:03 AM, Dan Carpenter wrote: > On Wed, May 06, 2015 at 04:28:22PM -0500, J. German Rivera wrote: >> +/* >> + * FIXME: Enable this code when the GIC-ITS MC support patch is merged >> + */ >> +#ifdef GIC_ITS_MC_SUPPORT >> +static int mc_bus_msi_prepare(struct irq_domain *domain, struct device *dev, >> + int nvec, msi_alloc_info_t *info) >> +{ >> + int error; >> + u32 its_dev_id; >> + struct dprc_attributes dprc_attr; >> + struct fsl_mc_device *mc_bus_dev = to_fsl_mc_device(dev); >> + >> + if (WARN_ON(!(mc_bus_dev->flags & FSL_MC_IS_DPRC))) >> + return -EINVAL; >> + >> + error = dprc_get_attributes(mc_bus_dev->mc_io, >> + mc_bus_dev->mc_handle, &dprc_attr); >> + if (error < 0) { >> + dev_err(&mc_bus_dev->dev, >> + "dprc_get_attributes() failed: %d\n", >> + error); >> + return error; >> + } >> + >> + /* >> + * Build 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. >> + */ >> + its_dev_id = mc_bus_dev->icid; >> + if (its_dev_id > STREAM_ID_ICID_MASK) { >> + dev_err(&mc_bus_dev->dev, >> + "Invalid ICID: %#x\n", its_dev_id); >> + return -ERANGE; >> + } >> + >> + if (dprc_attr.options & DPRC_CFG_OPT_IOMMU_BYPASS) >> + its_dev_id |= STREAM_ID_PL_MASK | STREAM_ID_BMT_MASK; >> + >> + return __its_msi_prepare(domain->parent, its_dev_id, dev, nvec, info); >> +} >> + >> +static void mc_bus_mask_msi_irq(struct irq_data *d) >> +{ >> + /* Bus specefic Mask */ >> + irq_chip_mask_parent(d); >> +} >> + >> +static void mc_bus_unmask_msi_irq(struct irq_data *d) >> +{ >> + /* Bus specefic unmask */ >> + irq_chip_unmask_parent(d); >> +} >> + >> +static void mc_bus_msi_domain_write_msg(struct irq_data *irq_data, >> + struct msi_msg *msg) >> +{ >> + struct msi_desc *msi_entry = irq_data->msi_desc; >> + struct fsl_mc_device *mc_bus_dev = to_fsl_mc_device(msi_entry->dev); >> + struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_bus_dev); >> + struct fsl_mc_device_irq *irq_res = >> + &mc_bus->irq_resources[msi_entry->msi_attrib.entry_nr]; >> + >> + if (irq_res->irq_number == irq_data->irq) { >> + /* >> + * write msg->address_hi/lo to irq_resource >> + */ >> + irq_res->msi_paddr = >> + ((u64)msg->address_hi << 32) | msg->address_lo; >> + irq_res->msi_value = msg->data; >> + } >> +} >> + >> +static struct irq_chip mc_bus_msi_irq_chip = { >> + .name = "fsl-mc-bus-msi", >> + .irq_unmask = mc_bus_unmask_msi_irq, >> + .irq_mask = mc_bus_mask_msi_irq, >> + .irq_eoi = irq_chip_eoi_parent, >> + .irq_write_msi_msg = mc_bus_msi_domain_write_msg, >> +}; >> + >> +static struct msi_domain_ops mc_bus_msi_ops = { >> + .msi_prepare = mc_bus_msi_prepare, >> +}; >> + >> +static struct msi_domain_info mc_bus_msi_domain_info = { >> + .flags = (MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS | >> + MSI_FLAG_MULTI_PCI_MSI | MSI_FLAG_PCI_MSIX), >> + .ops = &mc_bus_msi_ops, >> + .chip = &mc_bus_msi_irq_chip, >> +}; >> + >> +static int create_mc_irq_domain(struct platform_device *mc_pdev, >> + struct irq_domain **new_irq_domain) >> +{ >> + int error; >> + struct device_node *its_of_node; >> + struct irq_domain *its_domain; >> + struct irq_domain *irq_domain; >> + struct device_node *mc_of_node = mc_pdev->dev.of_node; >> + >> + its_of_node = of_parse_phandle(mc_of_node, "lpi-parent", 0); >> + if (!its_of_node) { >> + dev_err(&mc_pdev->dev, >> + "lpi-parent phandle missing for %s\n", >> + mc_of_node->full_name); >> + return -ENOENT; >> + } >> + >> + /* >> + * Extract MSI parent node: >> + */ >> + its_domain = irq_find_host(its_of_node); >> + if (!its_domain) { >> + dev_err(&mc_pdev->dev, "Unable to find parent domain\n"); >> + error = -ENOENT; >> + goto cleanup_its_of_node; >> + } >> + >> + /* >> + * FIXME: Enable this code when the GIC-ITS MC support patch is merged >> + */ >> +#ifdef GIC_ITS_MC_SUPPORT > > This #ifdef GIC_ITS_MC_SUPPORT is nested inside another #ifdef > GIC_ITS_MC_SUPPORT. Can you just delete all the ifdef code? It really > makes reviewing this complicated. > I'll remove the nested #ifdef. However, as I explained before, these #ifdefs are needed to be able to make the code compile without the GIC-ITS support in place. Of course, the code will not be moved out of staging with these #ifdefs. There is already an item for this in the drivers/staging/fsl-mc/TODO file. >> + irq_domain = msi_create_irq_domain(mc_of_node, &mc_bus_msi_domain_info, >> + its_domain->parent); >> + if (!irq_domain) { >> + dev_err(&mc_pdev->dev, "Failed to allocate msi_domain\n"); >> + error = -ENOMEM; >> + goto cleanup_its_of_node; >> + } >> + >> + dev_dbg(&mc_pdev->dev, "Allocated MSI domain\n"); >> +#else >> + irq_domain = NULL; >> +#endif >> + *new_irq_domain = irq_domain; >> + return 0; >> + >> +cleanup_its_of_node: >> + of_node_put(its_of_node); >> + return error; >> +} >> +#endif /* GIC_ITS_MC_SUPPORT */ > > regards, > dan carpenter > -- 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/