public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: "J. German Rivera" <German.Rivera@freescale.com>
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
Date: Thu, 7 May 2015 16:03:30 +0300	[thread overview]
Message-ID: <20150507130330.GI14154@mwanda> (raw)
In-Reply-To: <1430947708-10521-2-git-send-email-German.Rivera@freescale.com>

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

  reply	other threads:[~2015-05-07 13:03 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-06 21:28 [PATCH v2 0/7] staging: fsl-mc: New functionality to the MC bus driver J. German Rivera
2015-05-06 21:28 ` [PATCH v2 1/7] staging: fsl-mc: MC bus IRQ support J. German Rivera
2015-05-07 13:03   ` Dan Carpenter [this message]
2015-05-07 14:51     ` German Rivera
2015-05-07 20:01       ` Dan Carpenter
2015-05-10 13:14         ` Greg KH
2015-05-07 13:58   ` Dan Carpenter
2015-05-06 21:28 ` [PATCH v2 2/7] staging: fsl_-mc: add device binding path 'driver_override' J. German Rivera
2015-05-10 13:16   ` Greg KH
2015-05-06 21:28 ` [PATCH v2 3/7] staging: fsl-mc: Propagate driver_override for a child DPRC's children J. German Rivera
2015-05-06 21:28 ` [PATCH v2 4/7] staging: fsl-mc: Upgraded MC bus driver to match MC fw 7.0.0 J. German Rivera
2015-05-08  7:22   ` Dan Carpenter
2015-05-06 21:28 ` [PATCH v2 5/7] staging: fsl-mc: Allow the MC bus driver to run without GIC support J. German Rivera
2015-05-06 21:28 ` [PATCH v2 6/7] staging: fsl-mc: Add locking to serialize mc_send_command() calls J. German Rivera
2015-05-06 21:28 ` [PATCH v2 7/7] staging: fsl-mc: Use DPMCP IRQ and completion var to wait for MC J. German Rivera

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150507130330.GI14154@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=German.Rivera@freescale.com \
    --cc=R89243@freescale.com \
    --cc=agraf@suse.de \
    --cc=arnd@arndb.de \
    --cc=bhamciu1@freescale.com \
    --cc=bhupesh.sharma@freescale.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=itai.katz@freescale.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nir.erez@freescale.com \
    --cc=richard.schmitt@freescale.com \
    --cc=scottwood@freescale.com \
    --cc=stuart.yoder@freescale.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox