mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "J. German Rivera" <German.Rivera@freescale.com>
To: <gregkh@linuxfoundation.org>, <arnd@arndb.de>,
	<devel@driverdev.osuosl.org>, <linux-kernel@vger.kernel.org>
Cc: <stuart.yoder@freescale.com>, <itai.katz@freescale.com>,
	<scottwood@freescale.com>, <agraf@suse.de>,
	<bhamciu1@freescale.com>, <R89243@freescale.com>,
	<bhupesh.sharma@freescale.com>, <nir.erez@freescale.com>,
	<richard.schmitt@freescale.com>, <dan.carpenter@oracle.com>,
	"J. German Rivera" <German.Rivera@freescale.com>
Subject: [PATCH v4 5/7] staging: fsl-mc: Allow the MC bus driver to run without GIC support
Date: Tue, 9 Jun 2015 16:59:06 -0500	[thread overview]
Message-ID: <1433887148-2310-6-git-send-email-German.Rivera@freescale.com> (raw)
In-Reply-To: <1433887148-2310-1-git-send-email-German.Rivera@freescale.com>

If the msi-parent property is not present in the fsl,qoriq-mc node
of the device tree, the MC bus driver will assume that the GIC is not
supported.

This change is made in order to be able to use the MC bus driver in a
KVM VM, without having GIC-ITS support in guests. Added function
fsl_mc_interrupts_supported(), which can be called from DPAA2 object
drivers.

Signed-off-by: J. German Rivera <German.Rivera@freescale.com>
Reviewed-by: Stuart Yoder <stuart.yoder@freescale.com>
---
 drivers/staging/fsl-mc/bus/dprc-driver.c    | 31 +++++++++++++++++++----------
 drivers/staging/fsl-mc/bus/mc-allocator.c   |  4 ++++
 drivers/staging/fsl-mc/bus/mc-bus.c         | 16 +++++++++++++++
 drivers/staging/fsl-mc/include/mc-private.h |  4 ++++
 drivers/staging/fsl-mc/include/mc.h         |  2 ++
 5 files changed, 47 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/fsl-mc/bus/dprc-driver.c b/drivers/staging/fsl-mc/bus/dprc-driver.c
index 6bd20c0..dc97681 100644
--- a/drivers/staging/fsl-mc/bus/dprc-driver.c
+++ b/drivers/staging/fsl-mc/bus/dprc-driver.c
@@ -323,6 +323,7 @@ static int dprc_scan_container(struct fsl_mc_device *mc_bus_dev)
 	int error;
 	unsigned int irq_count;
 	struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_bus_dev);
+	struct fsl_mc *mc = dev_get_drvdata(fsl_mc_bus_type.dev_root->parent);

 	dprc_init_all_resource_pools(mc_bus_dev);

@@ -335,7 +336,7 @@ static int dprc_scan_container(struct fsl_mc_device *mc_bus_dev)
 	if (error < 0)
 		return error;

-	if (!mc_bus->irq_resources) {
+	if (mc->gic_supported && !mc_bus->irq_resources) {
 		irq_count += FSL_MC_IRQ_POOL_MAX_EXTRA_IRQS;
 		error = fsl_mc_populate_irq_pool(mc_bus, irq_count);
 		if (error < 0)
@@ -634,6 +635,7 @@ static int dprc_probe(struct fsl_mc_device *mc_dev)
 	struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_dev);
 	bool mc_io_created = false;
 	bool dev_root_set = false;
+	struct fsl_mc *mc = dev_get_drvdata(fsl_mc_bus_type.dev_root->parent);

 	if (WARN_ON(strcmp(mc_dev->obj_desc.type, "dprc") != 0))
 		return -EINVAL;
@@ -686,19 +688,23 @@ static int dprc_probe(struct fsl_mc_device *mc_dev)
 	if (error < 0)
 		goto error_cleanup_open;

-	/*
-	 * Configure interrupts for the DPRC object associated with this MC bus:
-	 */
-	error = dprc_setup_irqs(mc_dev);
-	if (error < 0)
-		goto error_cleanup_dprc_scan;
+	if (mc->gic_supported) {
+		/*
+		 * Configure interrupts for the DPRC object associated with
+		 * this MC bus:
+		 */
+		error = dprc_setup_irqs(mc_dev);
+		if (error < 0)
+			goto error_cleanup_dprc_scan;
+	}

 	dev_info(&mc_dev->dev, "DPRC device bound to driver");
 	return 0;

 error_cleanup_dprc_scan:
 	device_for_each_child(&mc_dev->dev, NULL, __fsl_mc_device_remove);
-	fsl_mc_cleanup_irq_pool(mc_bus);
+	if (mc->gic_supported)
+		fsl_mc_cleanup_irq_pool(mc_bus);

 error_cleanup_open:
 	(void)dprc_close(mc_dev->mc_io, mc_dev->mc_handle);
@@ -738,6 +744,7 @@ static int dprc_remove(struct fsl_mc_device *mc_dev)
 {
 	int error;
 	struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_dev);
+	struct fsl_mc *mc = dev_get_drvdata(fsl_mc_bus_type.dev_root->parent);

 	if (WARN_ON(strcmp(mc_dev->obj_desc.type, "dprc") != 0))
 		return -EINVAL;
@@ -747,13 +754,17 @@ static int dprc_remove(struct fsl_mc_device *mc_dev)
 	if (WARN_ON(!mc_bus->irq_resources))
 		return -EINVAL;

-	dprc_teardown_irqs(mc_dev);
+	if (mc->gic_supported)
+		dprc_teardown_irqs(mc_dev);
+
 	device_for_each_child(&mc_dev->dev, NULL, __fsl_mc_device_remove);
 	error = dprc_close(mc_dev->mc_io, mc_dev->mc_handle);
 	if (error < 0)
 		dev_err(&mc_dev->dev, "dprc_close() failed: %d\n", error);

-	fsl_mc_cleanup_irq_pool(mc_bus);
+	if (mc->gic_supported)
+		fsl_mc_cleanup_irq_pool(mc_bus);
+
 	dev_info(&mc_dev->dev, "DPRC device unbound from driver");
 	return 0;
 }
diff --git a/drivers/staging/fsl-mc/bus/mc-allocator.c b/drivers/staging/fsl-mc/bus/mc-allocator.c
index e445f79..3bdfefb 100644
--- a/drivers/staging/fsl-mc/bus/mc-allocator.c
+++ b/drivers/staging/fsl-mc/bus/mc-allocator.c
@@ -485,6 +485,10 @@ int __must_check fsl_mc_allocate_irqs(struct fsl_mc_device *mc_dev)
 	struct fsl_mc_device_irq **irqs = NULL;
 	struct fsl_mc_bus *mc_bus;
 	struct fsl_mc_resource_pool *res_pool;
+	struct fsl_mc *mc = dev_get_drvdata(fsl_mc_bus_type.dev_root->parent);
+
+	if (!mc->gic_supported)
+		return -ENOTSUPP;

 	if (WARN_ON(mc_dev->irqs))
 		return -EINVAL;
diff --git a/drivers/staging/fsl-mc/bus/mc-bus.c b/drivers/staging/fsl-mc/bus/mc-bus.c
index e5ea3ea..36bfe68 100644
--- a/drivers/staging/fsl-mc/bus/mc-bus.c
+++ b/drivers/staging/fsl-mc/bus/mc-bus.c
@@ -287,6 +287,14 @@ void fsl_mc_driver_unregister(struct fsl_mc_driver *mc_driver)
 }
 EXPORT_SYMBOL_GPL(fsl_mc_driver_unregister);

+bool fsl_mc_interrupts_supported(void)
+{
+	struct fsl_mc *mc = dev_get_drvdata(fsl_mc_bus_type.dev_root->parent);
+
+	return mc->gic_supported;
+}
+EXPORT_SYMBOL_GPL(fsl_mc_interrupts_supported);
+
 static int get_dprc_icid(struct fsl_mc_io *mc_io,
 			 int container_id, uint16_t *icid)
 {
@@ -839,6 +847,14 @@ static int fsl_mc_bus_probe(struct platform_device *pdev)
 	if (error < 0)
 		return error;

+	error = create_mc_irq_domain(pdev, &mc->irq_domain);
+	if (error < 0) {
+		dev_warn(&pdev->dev,
+			 "WARNING: MC bus driver will run without interrupt support\n");
+	} else {
+		mc->gic_supported = true;
+	}
+
 	/*
 	 * Get physical address of MC portal for the root DPRC:
 	 */
diff --git a/drivers/staging/fsl-mc/include/mc-private.h b/drivers/staging/fsl-mc/include/mc-private.h
index 8e02dc9..af7bd81 100644
--- a/drivers/staging/fsl-mc/include/mc-private.h
+++ b/drivers/staging/fsl-mc/include/mc-private.h
@@ -42,11 +42,15 @@
  * struct fsl_mc - Private data of a "fsl,qoriq-mc" platform device
  * @root_mc_bus_dev: MC object device representing the root DPRC
  * @irq_domain: IRQ domain for the fsl-mc bus type
+ * @gic_supported: boolean flag that indicates if the GIC interrupt controller
+ * is supported.
+ * @num_translation_ranges: number of entries in addr_translation_ranges
  * @addr_translation_ranges: array of bus to system address translation ranges
  */
 struct fsl_mc {
 	struct fsl_mc_device *root_mc_bus_dev;
 	struct irq_domain *irq_domain;
+	bool gic_supported;
 	u8 num_translation_ranges;
 	struct fsl_mc_addr_translation_range *translation_ranges;
 };
diff --git a/drivers/staging/fsl-mc/include/mc.h b/drivers/staging/fsl-mc/include/mc.h
index 7fa2816..56b7b47 100644
--- a/drivers/staging/fsl-mc/include/mc.h
+++ b/drivers/staging/fsl-mc/include/mc.h
@@ -209,6 +209,8 @@ int __must_check __fsl_mc_driver_register(struct fsl_mc_driver *fsl_mc_driver,

 void fsl_mc_driver_unregister(struct fsl_mc_driver *driver);

+bool fsl_mc_interrupts_supported(void);
+
 int __must_check fsl_mc_portal_allocate(struct fsl_mc_device *mc_dev,
 					uint16_t mc_io_flags,
 					struct fsl_mc_io **new_mc_io);
--
2.3.3


  parent reply	other threads:[~2015-06-09 22:24 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-09 21:59 [PATCH v4 0/7] staging: fsl-mc: New functionality to the MC bus driver J. German Rivera
2015-06-09 21:59 ` [PATCH v4 1/7] staging: fsl-mc: MC bus IRQ support J. German Rivera
2015-06-09 21:59 ` [PATCH v4 2/7] staging: fsl_-mc: add device binding path 'driver_override' J. German Rivera
2015-06-09 21:59 ` [PATCH v4 3/7] staging: fsl-mc: Propagate driver_override for a child DPRC's children J. German Rivera
2015-06-09 21:59 ` [PATCH v4 4/7] staging: fsl-mc: Upgraded MC bus driver to match MC fw 7.0.0 J. German Rivera
2015-06-09 21:59 ` J. German Rivera [this message]
2015-06-09 21:59 ` [PATCH v4 6/7] staging: fsl-mc: Add locking to serialize mc_send_command() calls J. German Rivera
2015-06-10 11:59   ` Dan Carpenter
2015-06-09 21:59 ` [PATCH v4 7/7] staging: fsl-mc: Use DPMCP IRQ and completion var to wait for MC J. German Rivera
2015-06-09 22:11 ` [PATCH v4 0/7] staging: fsl-mc: New functionality to the MC bus driver Fabio Estevam
2015-06-09 23:07   ` Jose Rivera
2015-06-13  0:18 ` Greg KH
2015-06-13  8:46   ` doubt about sm7xxfb (was: Re: [PATCH v4 0/7] staging: fsl-mc: New functionality to the MC bus driver) Sudip Mukherjee
2015-06-13 16:28     ` Greg KH
2015-06-13 16:57       ` Joe Perches
2015-06-15  5:17         ` Sudip Mukherjee
2015-06-15  6:36           ` Joe Perches
2015-06-19 10:29     ` Dan Carpenter
2015-06-20 11:20       ` Sudip Mukherjee
2015-06-18 15:01   ` [PATCH v4 0/7] staging: fsl-mc: New functionality to the MC bus driver Jose Rivera
2015-06-18 23:02     ` Greg KH

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=1433887148-2310-6-git-send-email-German.Rivera@freescale.com \
    --to=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=dan.carpenter@oracle.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

all inboxes | Powered by JetHome®