Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751548AbbEGND4 (ORCPT ); Thu, 7 May 2015 09:03:56 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:16723 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751061AbbEGNDw (ORCPT ); Thu, 7 May 2015 09:03:52 -0400 Date: Thu, 7 May 2015 16:03:30 +0300 From: Dan Carpenter To: "J. German Rivera" Cc: gregkh@linuxfoundation.org, arnd@arndb.de, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, stuart.yoder@freescale.com, bhupesh.sharma@freescale.com, agraf@suse.de, bhamciu1@freescale.com, nir.erez@freescale.com, itai.katz@freescale.com, scottwood@freescale.com, R89243@freescale.com, richard.schmitt@freescale.com Subject: Re: [PATCH v2 1/7] staging: fsl-mc: MC bus IRQ support Message-ID: <20150507130330.GI14154@mwanda> References: <1430947708-10521-1-git-send-email-German.Rivera@freescale.com> <1430947708-10521-2-git-send-email-German.Rivera@freescale.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1430947708-10521-2-git-send-email-German.Rivera@freescale.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Source-IP: aserv0022.oracle.com [141.146.126.234] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4693 Lines: 158 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. > + 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/