Re: [PATCH 02/10] staging: fsl-mc: Added generic MSI support for FSL-MC devices
From: Jiang Liu
Date: Tue Oct 27 2015 - 03:28:53 EST
On 2015/10/26 23:49, J. German Rivera wrote:
> Created an MSI domain for the fsl-mc bus-- including functions
> to create a domain, find a domain, alloc/free domain irqs, and
> bus specific overrides for domain and irq_chip ops.
>
> Signed-off-by: J. German Rivera <German.Rivera@xxxxxxxxxxxxx>
> ---
> drivers/staging/fsl-mc/bus/Kconfig | 1 +
> drivers/staging/fsl-mc/bus/Makefile | 1 +
> drivers/staging/fsl-mc/bus/mc-msi.c | 278 ++++++++++++++++++++++++++++
> drivers/staging/fsl-mc/include/mc-private.h | 17 ++
> drivers/staging/fsl-mc/include/mc.h | 17 ++
> 5 files changed, 314 insertions(+)
> create mode 100644 drivers/staging/fsl-mc/bus/mc-msi.c
>
<snit>
> +
> +static void fsl_mc_msi_free_descs(struct device *dev)
> +{
> + struct msi_desc *desc, *tmp;
> +
> + list_for_each_entry_safe(desc, tmp, dev_to_msi_list(dev), list) {
> + list_del(&desc->list);
> + free_msi_entry(desc);
> + }
> +}
> +
> +static int fsl_mc_msi_alloc_descs(struct device *dev, unsigned int irq_count)
> +
> +{
> + unsigned int i;
> + int error;
> + struct msi_desc *msi_desc;
> +
> + for (i = 0; i < irq_count; i++) {
> + msi_desc = alloc_msi_entry(dev);
> + if (!msi_desc) {
> + dev_err(dev, "Failed to allocate msi entry\n");
> + error = -ENOMEM;
> + goto cleanup_msi_descs;
> + }
> +
> + msi_desc->msi_attrib.is_msix = 1;
> + msi_desc->msi_attrib.is_64 = 1;
> + msi_desc->msi_attrib.entry_nr = i;
Hi Rivera,
Field msi_desc->msi_attrib is for PCI MSI only, it would be better to
introduce a dedicated structure for FSL-MC, just like
struct platform_msi_desc.
Thanks,
Gerry
> + msi_desc->nvec_used = 1;
> + INIT_LIST_HEAD(&msi_desc->list);
> + list_add_tail(&msi_desc->list, dev_to_msi_list(dev));
> + }
> +
> + return 0;
> +
> +cleanup_msi_descs:
> + fsl_mc_msi_free_descs(dev);
> + return error;
> +}
> +
> +int fsl_mc_msi_domain_alloc_irqs(struct device *dev,
> + unsigned int irq_count)
> +{
> + struct irq_domain *msi_domain;
> + int error;
> +
> + if (WARN_ON(!list_empty(dev_to_msi_list(dev))))
> + return -EINVAL;
> +
> + error = fsl_mc_msi_alloc_descs(dev, irq_count);
> + if (error < 0)
> + return error;
> +
> + msi_domain = dev_get_msi_domain(dev);
> + if (WARN_ON(!msi_domain)) {
> + error = -EINVAL;
> + goto cleanup_msi_descs;
> + }
> +
> + /*
> + * NOTE: Calling this function will trigger the invocation of the
> + * its_fsl_mc_msi_prepare() callback
> + */
> + error = msi_domain_alloc_irqs(msi_domain, dev, irq_count);
> +
> + if (error) {
> + dev_err(dev, "Failed to allocate IRQs\n");
> + goto cleanup_msi_descs;
> + }
> +
> + return 0;
> +
> +cleanup_msi_descs:
> + fsl_mc_msi_free_descs(dev);
> + return error;
> +}
> +
<snit>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/