linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/4] drives/soc/fsl: Move DPIO driver out of staging
@ 2018-03-26 19:05 Roy Pledge
  2018-03-26 19:05 ` [PATCH v3 1/4] drivers/staging/fsl-mc: Use memremap for DPIO cache enabled area Roy Pledge
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Roy Pledge @ 2018-03-26 19:05 UTC (permalink / raw)
  To: devel, linux-arm-kernel
  Cc: arnd, gregkh, horia.geanta, linux-kernel, leoyang.li, stuyoder,
	catalin.marinas, Roy Pledge, laurentiu.tudor

This patchset moves the NXP DPIO (Datapath I/O Driver) out of the
drivers/staging directory and into the drivers/soc/fsl directory.

The DPIO driver enables access to Queue and Buffer Manager (QBMAN)
hardware on NXP DPAA2 devices. This is a prerequiset to moving the
DPAA2 Etherney driver out of staging.

Changes in v3:
	- Update caam files that use dpaa2 frame header files
	- Fix spare errors and memory leak
	- Remove empty staging/drivers/fsl-mc directory

Changes in v2:
	- Fix minor conflict in latest linux-next branch
	- Generate patch using -M


Roy Pledge (4):
  drivers/staging/fsl-mc: Use memremap for DPIO cache enabled area
  drivers/staging/fsl-mc: Fix DPIO error path issues
  staging:fsl-mc: Move DPIO from staging to drivers/soc/fsl
  drivers/staging: Remove fsl-mc driver from staging

 MAINTAINERS                                        |  2 +-
 drivers/crypto/caam/sg_sw_qm2.h                    |  2 +-
 drivers/crypto/caam/sg_sw_sec4.h                   |  2 +-
 drivers/soc/fsl/Kconfig                            | 10 +++++
 drivers/soc/fsl/Makefile                           |  1 +
 .../{staging/fsl-mc/bus => soc/fsl}/dpio/Makefile  |  0
 .../fsl-mc/bus => soc/fsl}/dpio/dpio-cmd.h         |  0
 .../fsl-mc/bus => soc/fsl}/dpio/dpio-driver.c      | 51 +++++++++++++++-------
 .../fsl-mc/bus => soc/fsl}/dpio/dpio-driver.txt    |  0
 .../fsl-mc/bus => soc/fsl}/dpio/dpio-service.c     |  2 +-
 .../{staging/fsl-mc/bus => soc/fsl}/dpio/dpio.c    |  0
 .../{staging/fsl-mc/bus => soc/fsl}/dpio/dpio.h    |  0
 .../fsl-mc/bus => soc/fsl}/dpio/qbman-portal.c     |  2 +-
 .../fsl-mc/bus => soc/fsl}/dpio/qbman-portal.h     |  6 +--
 drivers/staging/Kconfig                            |  2 -
 drivers/staging/Makefile                           |  1 -
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h     |  4 +-
 drivers/staging/fsl-mc/Kconfig                     |  2 -
 drivers/staging/fsl-mc/Makefile                    |  3 --
 drivers/staging/fsl-mc/bus/Kconfig                 | 16 -------
 drivers/staging/fsl-mc/bus/Makefile                |  9 ----
 .../fsl-mc/include => include/soc/fsl}/dpaa2-fd.h  |  0
 .../include => include/soc/fsl}/dpaa2-global.h     |  0
 .../fsl-mc/include => include/soc/fsl}/dpaa2-io.h  |  2 +-
 24 files changed, 58 insertions(+), 59 deletions(-)
 rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/Makefile (100%)
 rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio-cmd.h (100%)
 rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio-driver.c (83%)
 rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio-driver.txt (100%)
 rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio-service.c (99%)
 rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio.c (100%)
 rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio.h (100%)
 rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/qbman-portal.c (99%)
 rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/qbman-portal.h (99%)
 delete mode 100644 drivers/staging/fsl-mc/Kconfig
 delete mode 100644 drivers/staging/fsl-mc/Makefile
 delete mode 100644 drivers/staging/fsl-mc/bus/Kconfig
 delete mode 100644 drivers/staging/fsl-mc/bus/Makefile
 rename {drivers/staging/fsl-mc/include => include/soc/fsl}/dpaa2-fd.h (100%)
 rename {drivers/staging/fsl-mc/include => include/soc/fsl}/dpaa2-global.h (100%)
 rename {drivers/staging/fsl-mc/include => include/soc/fsl}/dpaa2-io.h (99%)

--
2.7.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v3 1/4] drivers/staging/fsl-mc: Use memremap for DPIO cache enabled area
  2018-03-26 19:05 [PATCH v3 0/4] drives/soc/fsl: Move DPIO driver out of staging Roy Pledge
@ 2018-03-26 19:05 ` Roy Pledge
  2018-03-26 19:05 ` [PATCH v3 2/4] drivers/staging/fsl-mc: Fix DPIO error path issues Roy Pledge
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Roy Pledge @ 2018-03-26 19:05 UTC (permalink / raw)
  To: devel, linux-arm-kernel
  Cc: arnd, gregkh, horia.geanta, linux-kernel, leoyang.li, stuyoder,
	catalin.marinas, Roy Pledge, laurentiu.tudor

Change the mapping of the QBMan cache enabled area from using ioremap_wc()
to memremap(). This allows the __iomem attribute to be removed from the
pointer (which makes sense as accesses try this as cacheable memory not
IO memory).  These changes allow sparse checks to pass.

Signed-off-by: Roy Pledge <roy.pledge@nxp.com>
---
 drivers/staging/fsl-mc/bus/dpio/dpio-driver.c  | 8 +++++---
 drivers/staging/fsl-mc/bus/dpio/qbman-portal.h | 4 ++--
 drivers/staging/fsl-mc/include/dpaa2-io.h      | 2 +-
 3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/fsl-mc/bus/dpio/dpio-driver.c b/drivers/staging/fsl-mc/bus/dpio/dpio-driver.c
index 182b384..e00f473 100644
--- a/drivers/staging/fsl-mc/bus/dpio/dpio-driver.c
+++ b/drivers/staging/fsl-mc/bus/dpio/dpio-driver.c
@@ -13,6 +13,7 @@
 #include <linux/msi.h>
 #include <linux/dma-mapping.h>
 #include <linux/delay.h>
+#include <linux/io.h>
 
 #include <linux/fsl/mc.h>
 #include "../../include/dpaa2-io.h"
@@ -146,10 +147,11 @@ static int dpaa2_dpio_probe(struct fsl_mc_device *dpio_dev)
 	 * Set the CENA regs to be the cache inhibited area of the portal to
 	 * avoid coherency issues if a user migrates to another core.
 	 */
-	desc.regs_cena = ioremap_wc(dpio_dev->regions[1].start,
-		resource_size(&dpio_dev->regions[1]));
+	desc.regs_cena = memremap(dpio_dev->regions[1].start,
+				  resource_size(&dpio_dev->regions[1]),
+				  MEMREMAP_WC);
 	desc.regs_cinh = ioremap(dpio_dev->regions[1].start,
-		resource_size(&dpio_dev->regions[1]));
+				 resource_size(&dpio_dev->regions[1]));
 
 	err = fsl_mc_allocate_irqs(dpio_dev);
 	if (err) {
diff --git a/drivers/staging/fsl-mc/bus/dpio/qbman-portal.h b/drivers/staging/fsl-mc/bus/dpio/qbman-portal.h
index 4488a44..69db3c8 100644
--- a/drivers/staging/fsl-mc/bus/dpio/qbman-portal.h
+++ b/drivers/staging/fsl-mc/bus/dpio/qbman-portal.h
@@ -15,7 +15,7 @@ struct qbman_swp;
 /* qbman software portal descriptor structure */
 struct qbman_swp_desc {
 	void *cena_bar; /* Cache-enabled portal base address */
-	void *cinh_bar; /* Cache-inhibited portal base address */
+	void __iomem *cinh_bar; /* Cache-inhibited portal base address */
 	u32 qman_version;
 };
 
@@ -102,7 +102,7 @@ struct qbman_release_desc {
 /* portal data structure */
 struct qbman_swp {
 	const struct qbman_swp_desc *desc;
-	void __iomem *addr_cena;
+	void *addr_cena;
 	void __iomem *addr_cinh;
 
 	/* Management commands */
diff --git a/drivers/staging/fsl-mc/include/dpaa2-io.h b/drivers/staging/fsl-mc/include/dpaa2-io.h
index f71227d..ab51e40 100644
--- a/drivers/staging/fsl-mc/include/dpaa2-io.h
+++ b/drivers/staging/fsl-mc/include/dpaa2-io.h
@@ -52,7 +52,7 @@ struct dpaa2_io_desc {
 	int has_8prio;
 	int cpu;
 	void *regs_cena;
-	void *regs_cinh;
+	void __iomem *regs_cinh;
 	int dpio_id;
 	u32 qman_version;
 };
-- 
2.7.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v3 2/4] drivers/staging/fsl-mc: Fix DPIO error path issues
  2018-03-26 19:05 [PATCH v3 0/4] drives/soc/fsl: Move DPIO driver out of staging Roy Pledge
  2018-03-26 19:05 ` [PATCH v3 1/4] drivers/staging/fsl-mc: Use memremap for DPIO cache enabled area Roy Pledge
@ 2018-03-26 19:05 ` Roy Pledge
  2018-03-27 11:05   ` Robin Murphy
  2018-03-26 19:05 ` [PATCH v3 3/4] staging:fsl-mc: Move DPIO from staging to drivers/soc/fsl Roy Pledge
  2018-03-26 19:05 ` [PATCH v3 4/4] drivers/staging: Remove fsl-mc driver from staging Roy Pledge
  3 siblings, 1 reply; 7+ messages in thread
From: Roy Pledge @ 2018-03-26 19:05 UTC (permalink / raw)
  To: devel, linux-arm-kernel
  Cc: arnd, gregkh, horia.geanta, linux-kernel, leoyang.li, stuyoder,
	catalin.marinas, Roy Pledge, laurentiu.tudor

The error path in the dpaa2_dpio_probe() function was not properly
unmapping the QBMan device memory on the error path. This was also
missing from the dpaa2_dpio_release() function.

Also addresses a memory leak of the device private data structure.

Signed-off-by: Roy Pledge <roy.pledge@nxp.com>
---
 drivers/staging/fsl-mc/bus/dpio/dpio-driver.c | 49 +++++++++++++++++++--------
 1 file changed, 34 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/fsl-mc/bus/dpio/dpio-driver.c b/drivers/staging/fsl-mc/bus/dpio/dpio-driver.c
index e00f473..e7a0009 100644
--- a/drivers/staging/fsl-mc/bus/dpio/dpio-driver.c
+++ b/drivers/staging/fsl-mc/bus/dpio/dpio-driver.c
@@ -28,6 +28,7 @@ MODULE_DESCRIPTION("DPIO Driver");
 
 struct dpio_priv {
 	struct dpaa2_io *io;
+	struct dpaa2_io_desc desc;
 };
 
 static irqreturn_t dpio_irq_handler(int irq_num, void *arg)
@@ -85,7 +86,6 @@ static int register_dpio_irq_handlers(struct fsl_mc_device *dpio_dev, int cpu)
 static int dpaa2_dpio_probe(struct fsl_mc_device *dpio_dev)
 {
 	struct dpio_attr dpio_attrs;
-	struct dpaa2_io_desc desc;
 	struct dpio_priv *priv;
 	int err = -ENOMEM;
 	struct device *dev = &dpio_dev->dev;
@@ -117,7 +117,7 @@ static int dpaa2_dpio_probe(struct fsl_mc_device *dpio_dev)
 		dev_err(dev, "dpio_get_attributes() failed %d\n", err);
 		goto err_get_attr;
 	}
-	desc.qman_version = dpio_attrs.qbman_version;
+	priv->desc.qman_version = dpio_attrs.qbman_version;
 
 	err = dpio_enable(dpio_dev->mc_io, 0, dpio_dev->mc_handle);
 	if (err) {
@@ -126,9 +126,9 @@ static int dpaa2_dpio_probe(struct fsl_mc_device *dpio_dev)
 	}
 
 	/* initialize DPIO descriptor */
-	desc.receives_notifications = dpio_attrs.num_priorities ? 1 : 0;
-	desc.has_8prio = dpio_attrs.num_priorities == 8 ? 1 : 0;
-	desc.dpio_id = dpio_dev->obj_desc.id;
+	priv->desc.receives_notifications = dpio_attrs.num_priorities ? 1 : 0;
+	priv->desc.has_8prio = dpio_attrs.num_priorities == 8 ? 1 : 0;
+	priv->desc.dpio_id = dpio_dev->obj_desc.id;
 
 	/* get the cpu to use for the affinity hint */
 	if (next_cpu == -1)
@@ -139,19 +139,28 @@ static int dpaa2_dpio_probe(struct fsl_mc_device *dpio_dev)
 	if (!cpu_possible(next_cpu)) {
 		dev_err(dev, "probe failed. Number of DPIOs exceeds NR_CPUS.\n");
 		err = -ERANGE;
-		goto err_allocate_irqs;
+		goto err_too_many_cpu;
 	}
-	desc.cpu = next_cpu;
+	priv->desc.cpu = next_cpu;
 
 	/*
 	 * Set the CENA regs to be the cache inhibited area of the portal to
 	 * avoid coherency issues if a user migrates to another core.
 	 */
-	desc.regs_cena = memremap(dpio_dev->regions[1].start,
-				  resource_size(&dpio_dev->regions[1]),
-				  MEMREMAP_WC);
-	desc.regs_cinh = ioremap(dpio_dev->regions[1].start,
-				 resource_size(&dpio_dev->regions[1]));
+	priv->desc.regs_cena = memremap(dpio_dev->regions[1].start,
+					resource_size(&dpio_dev->regions[1]),
+					MEMREMAP_WC);
+	if (!priv->desc.regs_cena) {
+		dev_err(dev, "memremap failed\n");
+		goto err_too_many_cpu;
+	}
+
+	priv->desc.regs_cinh = ioremap(dpio_dev->regions[1].start,
+				       resource_size(&dpio_dev->regions[1]));
+	if (!priv->desc.regs_cinh) {
+		dev_err(dev, "ioremap failed\n");
+		goto err_ioremap_failed;
+	}
 
 	err = fsl_mc_allocate_irqs(dpio_dev);
 	if (err) {
@@ -159,11 +168,11 @@ static int dpaa2_dpio_probe(struct fsl_mc_device *dpio_dev)
 		goto err_allocate_irqs;
 	}
 
-	err = register_dpio_irq_handlers(dpio_dev, desc.cpu);
+	err = register_dpio_irq_handlers(dpio_dev, priv->desc.cpu);
 	if (err)
 		goto err_register_dpio_irq;
 
-	priv->io = dpaa2_io_create(&desc);
+	priv->io = dpaa2_io_create(&priv->desc);
 	if (!priv->io) {
 		dev_err(dev, "dpaa2_io_create failed\n");
 		goto err_dpaa2_io_create;
@@ -171,7 +180,7 @@ static int dpaa2_dpio_probe(struct fsl_mc_device *dpio_dev)
 
 	dev_info(dev, "probed\n");
 	dev_dbg(dev, "   receives_notifications = %d\n",
-		desc.receives_notifications);
+		priv->desc.receives_notifications);
 	dpio_close(dpio_dev->mc_io, 0, dpio_dev->mc_handle);
 	fsl_mc_portal_free(dpio_dev->mc_io);
 
@@ -182,6 +191,10 @@ static int dpaa2_dpio_probe(struct fsl_mc_device *dpio_dev)
 err_register_dpio_irq:
 	fsl_mc_free_irqs(dpio_dev);
 err_allocate_irqs:
+	iounmap(priv->desc.regs_cinh);
+err_ioremap_failed:
+	memunmap(priv->desc.regs_cena);
+err_too_many_cpu:
 	dpio_disable(dpio_dev->mc_io, 0, dpio_dev->mc_handle);
 err_get_attr:
 	dpio_close(dpio_dev->mc_io, 0, dpio_dev->mc_handle);
@@ -189,6 +202,7 @@ static int dpaa2_dpio_probe(struct fsl_mc_device *dpio_dev)
 	fsl_mc_portal_free(dpio_dev->mc_io);
 err_mcportal:
 	dev_set_drvdata(dev, NULL);
+	devm_kfree(dev, priv);
 err_priv_alloc:
 	return err;
 }
@@ -230,8 +244,13 @@ static int dpaa2_dpio_remove(struct fsl_mc_device *dpio_dev)
 
 	dpio_close(dpio_dev->mc_io, 0, dpio_dev->mc_handle);
 
+	iounmap(priv->desc.regs_cinh);
+	memunmap(priv->desc.regs_cena);
+
 	fsl_mc_portal_free(dpio_dev->mc_io);
 
+	devm_kfree(dev, priv);
+
 	dev_set_drvdata(dev, NULL);
 
 	return 0;
-- 
2.7.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v3 3/4] staging:fsl-mc: Move DPIO from staging to drivers/soc/fsl
  2018-03-26 19:05 [PATCH v3 0/4] drives/soc/fsl: Move DPIO driver out of staging Roy Pledge
  2018-03-26 19:05 ` [PATCH v3 1/4] drivers/staging/fsl-mc: Use memremap for DPIO cache enabled area Roy Pledge
  2018-03-26 19:05 ` [PATCH v3 2/4] drivers/staging/fsl-mc: Fix DPIO error path issues Roy Pledge
@ 2018-03-26 19:05 ` Roy Pledge
  2018-03-26 19:05 ` [PATCH v3 4/4] drivers/staging: Remove fsl-mc driver from staging Roy Pledge
  3 siblings, 0 replies; 7+ messages in thread
From: Roy Pledge @ 2018-03-26 19:05 UTC (permalink / raw)
  To: devel, linux-arm-kernel
  Cc: arnd, gregkh, horia.geanta, linux-kernel, leoyang.li, stuyoder,
	catalin.marinas, Roy Pledge, laurentiu.tudor

Move the NXP DPIO (Datapath I/O Driver) out of the
drivers/staging directory and into the drivers/soc/fsl directory.

The DPIO driver enables access to Queue and Buffer Manager (QBMAN)
hardware on NXP DPAA2 devices. This is a prerequisite to moving the
DPAA2 Ethernet driver out of staging.

Signed-off-by: Roy Pledge <roy.pledge@nxp.com>
---
 MAINTAINERS                                                    |  2 +-
 drivers/crypto/caam/sg_sw_qm2.h                                |  2 +-
 drivers/crypto/caam/sg_sw_sec4.h                               |  2 +-
 drivers/soc/fsl/Kconfig                                        | 10 ++++++++++
 drivers/soc/fsl/Makefile                                       |  1 +
 drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/Makefile          |  0
 drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio-cmd.h        |  0
 drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio-driver.c     |  2 +-
 drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio-driver.txt   |  0
 drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio-service.c    |  2 +-
 drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio.c            |  0
 drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio.h            |  0
 drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/qbman-portal.c    |  2 +-
 drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/qbman-portal.h    |  2 +-
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h                 |  4 ++--
 drivers/staging/fsl-mc/bus/Kconfig                             |  9 ---------
 drivers/staging/fsl-mc/bus/Makefile                            |  2 --
 {drivers/staging/fsl-mc/include => include/soc/fsl}/dpaa2-fd.h |  0
 .../staging/fsl-mc/include => include/soc/fsl}/dpaa2-global.h  |  0
 {drivers/staging/fsl-mc/include => include/soc/fsl}/dpaa2-io.h |  0
 20 files changed, 20 insertions(+), 20 deletions(-)
 rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/Makefile (100%)
 rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio-cmd.h (100%)
 rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio-driver.c (99%)
 rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio-driver.txt (100%)
 rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio-service.c (99%)
 rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio.c (100%)
 rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio.h (100%)
 rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/qbman-portal.c (99%)
 rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/qbman-portal.h (99%)
 rename {drivers/staging/fsl-mc/include => include/soc/fsl}/dpaa2-fd.h (100%)
 rename {drivers/staging/fsl-mc/include => include/soc/fsl}/dpaa2-global.h (100%)
 rename {drivers/staging/fsl-mc/include => include/soc/fsl}/dpaa2-io.h (100%)

diff --git a/MAINTAINERS b/MAINTAINERS
index dc74106..e2f234c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4375,7 +4375,7 @@ DPAA2 DATAPATH I/O (DPIO) DRIVER
 M:	Roy Pledge <Roy.Pledge@nxp.com>
 L:	linux-kernel@vger.kernel.org
 S:	Maintained
-F:	drivers/staging/fsl-mc/bus/dpio
+F:	drivers/soc/fsl/dpio
 
 DPAA2 ETHERNET DRIVER
 M:	Ioana Radulescu <ruxandra.radulescu@nxp.com>
diff --git a/drivers/crypto/caam/sg_sw_qm2.h b/drivers/crypto/caam/sg_sw_qm2.h
index 31b4407..b5b4c12 100644
--- a/drivers/crypto/caam/sg_sw_qm2.h
+++ b/drivers/crypto/caam/sg_sw_qm2.h
@@ -35,7 +35,7 @@
 #ifndef _SG_SW_QM2_H_
 #define _SG_SW_QM2_H_
 
-#include "../../../drivers/staging/fsl-mc/include/dpaa2-fd.h"
+#include <soc/fsl/dpaa2-fd.h>
 
 static inline void dma_to_qm_sg_one(struct dpaa2_sg_entry *qm_sg_ptr,
 				    dma_addr_t dma, u32 len, u16 offset)
diff --git a/drivers/crypto/caam/sg_sw_sec4.h b/drivers/crypto/caam/sg_sw_sec4.h
index e586ffa..dbfa9fc 100644
--- a/drivers/crypto/caam/sg_sw_sec4.h
+++ b/drivers/crypto/caam/sg_sw_sec4.h
@@ -12,7 +12,7 @@
 #include "ctrl.h"
 #include "regs.h"
 #include "sg_sw_qm2.h"
-#include "../../../drivers/staging/fsl-mc/include/dpaa2-fd.h"
+#include <soc/fsl/dpaa2-fd.h>
 
 struct sec4_sg_entry {
 	u64 ptr;
diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig
index 7a9fb9b..c17bf38 100644
--- a/drivers/soc/fsl/Kconfig
+++ b/drivers/soc/fsl/Kconfig
@@ -16,3 +16,13 @@ config FSL_GUTS
 	  Initially only reading SVR and registering soc device are supported.
 	  Other guts accesses, such as reading RCW, should eventually be moved
 	  into this driver as well.
+
+config FSL_MC_DPIO
+        tristate "QorIQ DPAA2 DPIO driver"
+        depends on FSL_MC_BUS
+        help
+	  Driver for the DPAA2 DPIO object.  A DPIO provides queue and
+	  buffer management facilities for software to interact with
+	  other DPAA2 objects. This driver does not expose the DPIO
+	  objects individually, but groups them under a service layer
+	  API.
diff --git a/drivers/soc/fsl/Makefile b/drivers/soc/fsl/Makefile
index 44b3beb..803ef1b 100644
--- a/drivers/soc/fsl/Makefile
+++ b/drivers/soc/fsl/Makefile
@@ -6,3 +6,4 @@ obj-$(CONFIG_FSL_DPAA)                 += qbman/
 obj-$(CONFIG_QUICC_ENGINE)		+= qe/
 obj-$(CONFIG_CPM)			+= qe/
 obj-$(CONFIG_FSL_GUTS)			+= guts.o
+obj-$(CONFIG_FSL_MC_DPIO) 		+= dpio/
diff --git a/drivers/staging/fsl-mc/bus/dpio/Makefile b/drivers/soc/fsl/dpio/Makefile
similarity index 100%
rename from drivers/staging/fsl-mc/bus/dpio/Makefile
rename to drivers/soc/fsl/dpio/Makefile
diff --git a/drivers/staging/fsl-mc/bus/dpio/dpio-cmd.h b/drivers/soc/fsl/dpio/dpio-cmd.h
similarity index 100%
rename from drivers/staging/fsl-mc/bus/dpio/dpio-cmd.h
rename to drivers/soc/fsl/dpio/dpio-cmd.h
diff --git a/drivers/staging/fsl-mc/bus/dpio/dpio-driver.c b/drivers/soc/fsl/dpio/dpio-driver.c
similarity index 99%
rename from drivers/staging/fsl-mc/bus/dpio/dpio-driver.c
rename to drivers/soc/fsl/dpio/dpio-driver.c
index e7a0009..3fd34e9 100644
--- a/drivers/staging/fsl-mc/bus/dpio/dpio-driver.c
+++ b/drivers/soc/fsl/dpio/dpio-driver.c
@@ -16,7 +16,7 @@
 #include <linux/io.h>
 
 #include <linux/fsl/mc.h>
-#include "../../include/dpaa2-io.h"
+#include <soc/fsl/dpaa2-io.h>
 
 #include "qbman-portal.h"
 #include "dpio.h"
diff --git a/drivers/staging/fsl-mc/bus/dpio/dpio-driver.txt b/drivers/soc/fsl/dpio/dpio-driver.txt
similarity index 100%
rename from drivers/staging/fsl-mc/bus/dpio/dpio-driver.txt
rename to drivers/soc/fsl/dpio/dpio-driver.txt
diff --git a/drivers/staging/fsl-mc/bus/dpio/dpio-service.c b/drivers/soc/fsl/dpio/dpio-service.c
similarity index 99%
rename from drivers/staging/fsl-mc/bus/dpio/dpio-service.c
rename to drivers/soc/fsl/dpio/dpio-service.c
index 14ed2be..9b17f72 100644
--- a/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
+++ b/drivers/soc/fsl/dpio/dpio-service.c
@@ -6,7 +6,7 @@
  */
 #include <linux/types.h>
 #include <linux/fsl/mc.h>
-#include "../../include/dpaa2-io.h"
+#include <soc/fsl/dpaa2-io.h>
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
diff --git a/drivers/staging/fsl-mc/bus/dpio/dpio.c b/drivers/soc/fsl/dpio/dpio.c
similarity index 100%
rename from drivers/staging/fsl-mc/bus/dpio/dpio.c
rename to drivers/soc/fsl/dpio/dpio.c
diff --git a/drivers/staging/fsl-mc/bus/dpio/dpio.h b/drivers/soc/fsl/dpio/dpio.h
similarity index 100%
rename from drivers/staging/fsl-mc/bus/dpio/dpio.h
rename to drivers/soc/fsl/dpio/dpio.h
diff --git a/drivers/staging/fsl-mc/bus/dpio/qbman-portal.c b/drivers/soc/fsl/dpio/qbman-portal.c
similarity index 99%
rename from drivers/staging/fsl-mc/bus/dpio/qbman-portal.c
rename to drivers/soc/fsl/dpio/qbman-portal.c
index 116fafb..cf1d448 100644
--- a/drivers/staging/fsl-mc/bus/dpio/qbman-portal.c
+++ b/drivers/soc/fsl/dpio/qbman-portal.c
@@ -8,7 +8,7 @@
 #include <asm/cacheflush.h>
 #include <linux/io.h>
 #include <linux/slab.h>
-#include "../../include/dpaa2-global.h"
+#include <soc/fsl/dpaa2-global.h>
 
 #include "qbman-portal.h"
 
diff --git a/drivers/staging/fsl-mc/bus/dpio/qbman-portal.h b/drivers/soc/fsl/dpio/qbman-portal.h
similarity index 99%
rename from drivers/staging/fsl-mc/bus/dpio/qbman-portal.h
rename to drivers/soc/fsl/dpio/qbman-portal.h
index 69db3c8..89d1dd9 100644
--- a/drivers/staging/fsl-mc/bus/dpio/qbman-portal.h
+++ b/drivers/soc/fsl/dpio/qbman-portal.h
@@ -7,7 +7,7 @@
 #ifndef __FSL_QBMAN_PORTAL_H
 #define __FSL_QBMAN_PORTAL_H
 
-#include "../../include/dpaa2-fd.h"
+#include <soc/fsl/dpaa2-fd.h>
 
 struct dpaa2_dq;
 struct qbman_swp;
diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
index b8990cf..24ae387 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
@@ -37,8 +37,8 @@
 #include <linux/if_vlan.h>
 #include <linux/fsl/mc.h>
 
-#include "../../fsl-mc/include/dpaa2-io.h"
-#include "../../fsl-mc/include/dpaa2-fd.h"
+#include <soc/fsl/dpaa2-io.h>
+#include <soc/fsl/dpaa2-fd.h>
 #include "dpni.h"
 #include "dpni-cmd.h"
 
diff --git a/drivers/staging/fsl-mc/bus/Kconfig b/drivers/staging/fsl-mc/bus/Kconfig
index 3424530..90f234d 100644
--- a/drivers/staging/fsl-mc/bus/Kconfig
+++ b/drivers/staging/fsl-mc/bus/Kconfig
@@ -5,12 +5,3 @@
 # Copyright (C) 2014-2016 Freescale Semiconductor, Inc.
 #
 
-config FSL_MC_DPIO
-        tristate "QorIQ DPAA2 DPIO driver"
-        depends on FSL_MC_BUS
-        help
-	  Driver for the DPAA2 DPIO object.  A DPIO provides queue and
-	  buffer management facilities for software to interact with
-	  other DPAA2 objects. This driver does not expose the DPIO
-	  objects individually, but groups them under a service layer
-	  API.
diff --git a/drivers/staging/fsl-mc/bus/Makefile b/drivers/staging/fsl-mc/bus/Makefile
index 21d8ebc..2141e4b 100644
--- a/drivers/staging/fsl-mc/bus/Makefile
+++ b/drivers/staging/fsl-mc/bus/Makefile
@@ -5,5 +5,3 @@
 # Copyright (C) 2014 Freescale Semiconductor, Inc.
 #
 
-# MC DPIO driver
-obj-$(CONFIG_FSL_MC_DPIO) += dpio/
diff --git a/drivers/staging/fsl-mc/include/dpaa2-fd.h b/include/soc/fsl/dpaa2-fd.h
similarity index 100%
rename from drivers/staging/fsl-mc/include/dpaa2-fd.h
rename to include/soc/fsl/dpaa2-fd.h
diff --git a/drivers/staging/fsl-mc/include/dpaa2-global.h b/include/soc/fsl/dpaa2-global.h
similarity index 100%
rename from drivers/staging/fsl-mc/include/dpaa2-global.h
rename to include/soc/fsl/dpaa2-global.h
diff --git a/drivers/staging/fsl-mc/include/dpaa2-io.h b/include/soc/fsl/dpaa2-io.h
similarity index 100%
rename from drivers/staging/fsl-mc/include/dpaa2-io.h
rename to include/soc/fsl/dpaa2-io.h
-- 
2.7.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v3 4/4] drivers/staging: Remove fsl-mc driver from staging
  2018-03-26 19:05 [PATCH v3 0/4] drives/soc/fsl: Move DPIO driver out of staging Roy Pledge
                   ` (2 preceding siblings ...)
  2018-03-26 19:05 ` [PATCH v3 3/4] staging:fsl-mc: Move DPIO from staging to drivers/soc/fsl Roy Pledge
@ 2018-03-26 19:05 ` Roy Pledge
  3 siblings, 0 replies; 7+ messages in thread
From: Roy Pledge @ 2018-03-26 19:05 UTC (permalink / raw)
  To: devel, linux-arm-kernel
  Cc: arnd, gregkh, horia.geanta, linux-kernel, leoyang.li, stuyoder,
	catalin.marinas, Roy Pledge, laurentiu.tudor

Remove the staging/drivers/fsl-mc directory from the staging
area now that all the components have been moved to the main
kernel areas.

Signed-off-by: Roy Pledge <roy.pledge@nxp.com>
---
 drivers/staging/Kconfig             | 2 --
 drivers/staging/Makefile            | 1 -
 drivers/staging/fsl-mc/Kconfig      | 2 --
 drivers/staging/fsl-mc/Makefile     | 3 ---
 drivers/staging/fsl-mc/bus/Kconfig  | 7 -------
 drivers/staging/fsl-mc/bus/Makefile | 7 -------
 6 files changed, 22 deletions(-)
 delete mode 100644 drivers/staging/fsl-mc/Kconfig
 delete mode 100644 drivers/staging/fsl-mc/Makefile
 delete mode 100644 drivers/staging/fsl-mc/bus/Kconfig
 delete mode 100644 drivers/staging/fsl-mc/bus/Makefile

diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig
index d5926f0..a0f262a 100644
--- a/drivers/staging/Kconfig
+++ b/drivers/staging/Kconfig
@@ -98,8 +98,6 @@ source "drivers/staging/clocking-wizard/Kconfig"
 
 source "drivers/staging/fbtft/Kconfig"
 
-source "drivers/staging/fsl-mc/Kconfig"
-
 source "drivers/staging/fsl-dpaa2/Kconfig"
 
 source "drivers/staging/wilc1000/Kconfig"
diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile
index 919753c..326a1e8 100644
--- a/drivers/staging/Makefile
+++ b/drivers/staging/Makefile
@@ -40,7 +40,6 @@ obj-$(CONFIG_CRYPTO_SKEIN)	+= skein/
 obj-$(CONFIG_UNISYSSPAR)	+= unisys/
 obj-$(CONFIG_COMMON_CLK_XLNX_CLKWZRD)	+= clocking-wizard/
 obj-$(CONFIG_FB_TFT)		+= fbtft/
-obj-$(CONFIG_FSL_MC_BUS)	+= fsl-mc/
 obj-$(CONFIG_FSL_DPAA2)		+= fsl-dpaa2/
 obj-$(CONFIG_WILC1000)		+= wilc1000/
 obj-$(CONFIG_MOST)		+= most/
diff --git a/drivers/staging/fsl-mc/Kconfig b/drivers/staging/fsl-mc/Kconfig
deleted file mode 100644
index 3002229..0000000
--- a/drivers/staging/fsl-mc/Kconfig
+++ /dev/null
@@ -1,2 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-source "drivers/staging/fsl-mc/bus/Kconfig"
diff --git a/drivers/staging/fsl-mc/Makefile b/drivers/staging/fsl-mc/Makefile
deleted file mode 100644
index 1468388..0000000
--- a/drivers/staging/fsl-mc/Makefile
+++ /dev/null
@@ -1,3 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-# Freescale Management Complex (MC) bus drivers
-obj-$(CONFIG_FSL_MC_BUS)	+= bus/
diff --git a/drivers/staging/fsl-mc/bus/Kconfig b/drivers/staging/fsl-mc/bus/Kconfig
deleted file mode 100644
index 90f234d..0000000
--- a/drivers/staging/fsl-mc/bus/Kconfig
+++ /dev/null
@@ -1,7 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-#
-# DPAA2 fsl-mc bus
-#
-# Copyright (C) 2014-2016 Freescale Semiconductor, Inc.
-#
-
diff --git a/drivers/staging/fsl-mc/bus/Makefile b/drivers/staging/fsl-mc/bus/Makefile
deleted file mode 100644
index 2141e4b..0000000
--- a/drivers/staging/fsl-mc/bus/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-#
-# Freescale Management Complex (MC) bus drivers
-#
-# Copyright (C) 2014 Freescale Semiconductor, Inc.
-#
-
-- 
2.7.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v3 2/4] drivers/staging/fsl-mc: Fix DPIO error path issues
  2018-03-26 19:05 ` [PATCH v3 2/4] drivers/staging/fsl-mc: Fix DPIO error path issues Roy Pledge
@ 2018-03-27 11:05   ` Robin Murphy
  2018-03-27 13:19     ` Roy Pledge
  0 siblings, 1 reply; 7+ messages in thread
From: Robin Murphy @ 2018-03-27 11:05 UTC (permalink / raw)
  To: roy.pledge, devel, linux-arm-kernel
  Cc: catalin.marinas, arnd, gregkh, linux-kernel, leoyang.li,
	stuyoder, horia.geanta, laurentiu.tudor

Hi Roy,

On 26/03/18 20:05, Roy Pledge wrote:
> The error path in the dpaa2_dpio_probe() function was not properly
> unmapping the QBMan device memory on the error path. This was also
> missing from the dpaa2_dpio_release() function.
> 
> Also addresses a memory leak of the device private data structure.
> 
> Signed-off-by: Roy Pledge <roy.pledge@nxp.com>
> ---
>   drivers/staging/fsl-mc/bus/dpio/dpio-driver.c | 49 +++++++++++++++++++--------
>   1 file changed, 34 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/staging/fsl-mc/bus/dpio/dpio-driver.c b/drivers/staging/fsl-mc/bus/dpio/dpio-driver.c
> index e00f473..e7a0009 100644
> --- a/drivers/staging/fsl-mc/bus/dpio/dpio-driver.c
> +++ b/drivers/staging/fsl-mc/bus/dpio/dpio-driver.c
> @@ -28,6 +28,7 @@ MODULE_DESCRIPTION("DPIO Driver");
>   
>   struct dpio_priv {
>   	struct dpaa2_io *io;
> +	struct dpaa2_io_desc desc;
>   };
>   
>   static irqreturn_t dpio_irq_handler(int irq_num, void *arg)
> @@ -85,7 +86,6 @@ static int register_dpio_irq_handlers(struct fsl_mc_device *dpio_dev, int cpu)
>   static int dpaa2_dpio_probe(struct fsl_mc_device *dpio_dev)
>   {
>   	struct dpio_attr dpio_attrs;
> -	struct dpaa2_io_desc desc;
>   	struct dpio_priv *priv;
>   	int err = -ENOMEM;
>   	struct device *dev = &dpio_dev->dev;
> @@ -117,7 +117,7 @@ static int dpaa2_dpio_probe(struct fsl_mc_device *dpio_dev)
>   		dev_err(dev, "dpio_get_attributes() failed %d\n", err);
>   		goto err_get_attr;
>   	}
> -	desc.qman_version = dpio_attrs.qbman_version;
> +	priv->desc.qman_version = dpio_attrs.qbman_version;
>   
>   	err = dpio_enable(dpio_dev->mc_io, 0, dpio_dev->mc_handle);
>   	if (err) {
> @@ -126,9 +126,9 @@ static int dpaa2_dpio_probe(struct fsl_mc_device *dpio_dev)
>   	}
>   
>   	/* initialize DPIO descriptor */
> -	desc.receives_notifications = dpio_attrs.num_priorities ? 1 : 0;
> -	desc.has_8prio = dpio_attrs.num_priorities == 8 ? 1 : 0;
> -	desc.dpio_id = dpio_dev->obj_desc.id;
> +	priv->desc.receives_notifications = dpio_attrs.num_priorities ? 1 : 0;
> +	priv->desc.has_8prio = dpio_attrs.num_priorities == 8 ? 1 : 0;
> +	priv->desc.dpio_id = dpio_dev->obj_desc.id;
>   
>   	/* get the cpu to use for the affinity hint */
>   	if (next_cpu == -1)
> @@ -139,19 +139,28 @@ static int dpaa2_dpio_probe(struct fsl_mc_device *dpio_dev)
>   	if (!cpu_possible(next_cpu)) {
>   		dev_err(dev, "probe failed. Number of DPIOs exceeds NR_CPUS.\n");
>   		err = -ERANGE;
> -		goto err_allocate_irqs;
> +		goto err_too_many_cpu;
>   	}
> -	desc.cpu = next_cpu;
> +	priv->desc.cpu = next_cpu;
>   
>   	/*
>   	 * Set the CENA regs to be the cache inhibited area of the portal to
>   	 * avoid coherency issues if a user migrates to another core.
>   	 */
> -	desc.regs_cena = memremap(dpio_dev->regions[1].start,
> -				  resource_size(&dpio_dev->regions[1]),
> -				  MEMREMAP_WC);
> -	desc.regs_cinh = ioremap(dpio_dev->regions[1].start,
> -				 resource_size(&dpio_dev->regions[1]));
> +	priv->desc.regs_cena = memremap(dpio_dev->regions[1].start,
> +					resource_size(&dpio_dev->regions[1]),
> +					MEMREMAP_WC);

Since you already have some devres-managed resources in this driver, 
maybe use devm_memremap? (and perhaps convert the existing ioremap too)

> +	if (!priv->desc.regs_cena) {
> +		dev_err(dev, "memremap failed\n");
> +		goto err_too_many_cpu;
> +	}
> +
> +	priv->desc.regs_cinh = ioremap(dpio_dev->regions[1].start,
> +				       resource_size(&dpio_dev->regions[1]));
> +	if (!priv->desc.regs_cinh) {
> +		dev_err(dev, "ioremap failed\n");
> +		goto err_ioremap_failed;
> +	}
>   
>   	err = fsl_mc_allocate_irqs(dpio_dev);
>   	if (err) {
> @@ -159,11 +168,11 @@ static int dpaa2_dpio_probe(struct fsl_mc_device *dpio_dev)
>   		goto err_allocate_irqs;
>   	}
>   
> -	err = register_dpio_irq_handlers(dpio_dev, desc.cpu);
> +	err = register_dpio_irq_handlers(dpio_dev, priv->desc.cpu);
>   	if (err)
>   		goto err_register_dpio_irq;
>   
> -	priv->io = dpaa2_io_create(&desc);
> +	priv->io = dpaa2_io_create(&priv->desc);
>   	if (!priv->io) {
>   		dev_err(dev, "dpaa2_io_create failed\n");
>   		goto err_dpaa2_io_create;
> @@ -171,7 +180,7 @@ static int dpaa2_dpio_probe(struct fsl_mc_device *dpio_dev)
>   
>   	dev_info(dev, "probed\n");
>   	dev_dbg(dev, "   receives_notifications = %d\n",
> -		desc.receives_notifications);
> +		priv->desc.receives_notifications);
>   	dpio_close(dpio_dev->mc_io, 0, dpio_dev->mc_handle);
>   	fsl_mc_portal_free(dpio_dev->mc_io);
>   
> @@ -182,6 +191,10 @@ static int dpaa2_dpio_probe(struct fsl_mc_device *dpio_dev)
>   err_register_dpio_irq:
>   	fsl_mc_free_irqs(dpio_dev);
>   err_allocate_irqs:
> +	iounmap(priv->desc.regs_cinh);
> +err_ioremap_failed:
> +	memunmap(priv->desc.regs_cena);

...then you wouldn't need to worry about this.

> +err_too_many_cpu:
>   	dpio_disable(dpio_dev->mc_io, 0, dpio_dev->mc_handle);
>   err_get_attr:
>   	dpio_close(dpio_dev->mc_io, 0, dpio_dev->mc_handle);
> @@ -189,6 +202,7 @@ static int dpaa2_dpio_probe(struct fsl_mc_device *dpio_dev)
>   	fsl_mc_portal_free(dpio_dev->mc_io);
>   err_mcportal:
>   	dev_set_drvdata(dev, NULL);
> +	devm_kfree(dev, priv);

The whole point of devm_* is that you don't need to do this - the devres 
entries are freed automatically by the driver core upon probe failure or 
driver detach, i.e. priv was never leaking.

>   err_priv_alloc:
>   	return err;
>   }
> @@ -230,8 +244,13 @@ static int dpaa2_dpio_remove(struct fsl_mc_device *dpio_dev)
>   
>   	dpio_close(dpio_dev->mc_io, 0, dpio_dev->mc_handle);
>   
> +	iounmap(priv->desc.regs_cinh);
> +	memunmap(priv->desc.regs_cena);
> +
>   	fsl_mc_portal_free(dpio_dev->mc_io);
>   
> +	devm_kfree(dev, priv);
> +
>   	dev_set_drvdata(dev, NULL);

Note that clearing drvdata is something else the driver core already 
does at about the same time as cleaning up devres entries (see 
__device_release_driver() and the failure path of really_probe(), in 
drivers/base/dd.c), so this has been similarly superfluous all along.

Robin.
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v3 2/4] drivers/staging/fsl-mc: Fix DPIO error path issues
  2018-03-27 11:05   ` Robin Murphy
@ 2018-03-27 13:19     ` Roy Pledge
  0 siblings, 0 replies; 7+ messages in thread
From: Roy Pledge @ 2018-03-27 13:19 UTC (permalink / raw)
  To: Robin Murphy, devel, linux-arm-kernel
  Cc: Ruxandra Ioana Ciocoi Radulescu, arnd, gregkh, Horia Geantă,
	linux-kernel, Leo Li, stuyoder, catalin.marinas, Laurentiu Tudor

On 3/27/2018 7:05 AM, Robin Murphy wrote:
> Hi Roy,
>
> On 26/03/18 20:05, Roy Pledge wrote:
>> The error path in the dpaa2_dpio_probe() function was not properly
>> unmapping the QBMan device memory on the error path. This was also
>> missing from the dpaa2_dpio_release() function.
>>
>> Also addresses a memory leak of the device private data structure.
>>
>> Signed-off-by: Roy Pledge <roy.pledge@nxp.com>
>> ---
>>    drivers/staging/fsl-mc/bus/dpio/dpio-driver.c | 49 +++++++++++++++++++--------
>>    1 file changed, 34 insertions(+), 15 deletions(-)
>>
>> diff --git a/drivers/staging/fsl-mc/bus/dpio/dpio-driver.c b/drivers/staging/fsl-mc/bus/dpio/dpio-driver.c
>> index e00f473..e7a0009 100644
>> --- a/drivers/staging/fsl-mc/bus/dpio/dpio-driver.c
>> +++ b/drivers/staging/fsl-mc/bus/dpio/dpio-driver.c
>> @@ -28,6 +28,7 @@ MODULE_DESCRIPTION("DPIO Driver");
>>    
>>    struct dpio_priv {
>>    	struct dpaa2_io *io;
>> +	struct dpaa2_io_desc desc;
>>    };
>>    
>>    static irqreturn_t dpio_irq_handler(int irq_num, void *arg)
>> @@ -85,7 +86,6 @@ static int register_dpio_irq_handlers(struct fsl_mc_device *dpio_dev, int cpu)
>>    static int dpaa2_dpio_probe(struct fsl_mc_device *dpio_dev)
>>    {
>>    	struct dpio_attr dpio_attrs;
>> -	struct dpaa2_io_desc desc;
>>    	struct dpio_priv *priv;
>>    	int err = -ENOMEM;
>>    	struct device *dev = &dpio_dev->dev;
>> @@ -117,7 +117,7 @@ static int dpaa2_dpio_probe(struct fsl_mc_device *dpio_dev)
>>    		dev_err(dev, "dpio_get_attributes() failed %d\n", err);
>>    		goto err_get_attr;
>>    	}
>> -	desc.qman_version = dpio_attrs.qbman_version;
>> +	priv->desc.qman_version = dpio_attrs.qbman_version;
>>    
>>    	err = dpio_enable(dpio_dev->mc_io, 0, dpio_dev->mc_handle);
>>    	if (err) {
>> @@ -126,9 +126,9 @@ static int dpaa2_dpio_probe(struct fsl_mc_device *dpio_dev)
>>    	}
>>    
>>    	/* initialize DPIO descriptor */
>> -	desc.receives_notifications = dpio_attrs.num_priorities ? 1 : 0;
>> -	desc.has_8prio = dpio_attrs.num_priorities == 8 ? 1 : 0;
>> -	desc.dpio_id = dpio_dev->obj_desc.id;
>> +	priv->desc.receives_notifications = dpio_attrs.num_priorities ? 1 : 0;
>> +	priv->desc.has_8prio = dpio_attrs.num_priorities == 8 ? 1 : 0;
>> +	priv->desc.dpio_id = dpio_dev->obj_desc.id;
>>    
>>    	/* get the cpu to use for the affinity hint */
>>    	if (next_cpu == -1)
>> @@ -139,19 +139,28 @@ static int dpaa2_dpio_probe(struct fsl_mc_device *dpio_dev)
>>    	if (!cpu_possible(next_cpu)) {
>>    		dev_err(dev, "probe failed. Number of DPIOs exceeds NR_CPUS.\n");
>>    		err = -ERANGE;
>> -		goto err_allocate_irqs;
>> +		goto err_too_many_cpu;
>>    	}
>> -	desc.cpu = next_cpu;
>> +	priv->desc.cpu = next_cpu;
>>    
>>    	/*
>>    	 * Set the CENA regs to be the cache inhibited area of the portal to
>>    	 * avoid coherency issues if a user migrates to another core.
>>    	 */
>> -	desc.regs_cena = memremap(dpio_dev->regions[1].start,
>> -				  resource_size(&dpio_dev->regions[1]),
>> -				  MEMREMAP_WC);
>> -	desc.regs_cinh = ioremap(dpio_dev->regions[1].start,
>> -				 resource_size(&dpio_dev->regions[1]));
>> +	priv->desc.regs_cena = memremap(dpio_dev->regions[1].start,
>> +					resource_size(&dpio_dev->regions[1]),
>> +					MEMREMAP_WC);
> Since you already have some devres-managed resources in this driver,
> maybe use devm_memremap? (and perhaps convert the existing ioremap too)
That would make since - will do.
>
>> +	if (!priv->desc.regs_cena) {
>> +		dev_err(dev, "memremap failed\n");
>> +		goto err_too_many_cpu;
>> +	}
>> +
>> +	priv->desc.regs_cinh = ioremap(dpio_dev->regions[1].start,
>> +				       resource_size(&dpio_dev->regions[1]));
>> +	if (!priv->desc.regs_cinh) {
>> +		dev_err(dev, "ioremap failed\n");
>> +		goto err_ioremap_failed;
>> +	}
>>    
>>    	err = fsl_mc_allocate_irqs(dpio_dev);
>>    	if (err) {
>> @@ -159,11 +168,11 @@ static int dpaa2_dpio_probe(struct fsl_mc_device *dpio_dev)
>>    		goto err_allocate_irqs;
>>    	}
>>    
>> -	err = register_dpio_irq_handlers(dpio_dev, desc.cpu);
>> +	err = register_dpio_irq_handlers(dpio_dev, priv->desc.cpu);
>>    	if (err)
>>    		goto err_register_dpio_irq;
>>    
>> -	priv->io = dpaa2_io_create(&desc);
>> +	priv->io = dpaa2_io_create(&priv->desc);
>>    	if (!priv->io) {
>>    		dev_err(dev, "dpaa2_io_create failed\n");
>>    		goto err_dpaa2_io_create;
>> @@ -171,7 +180,7 @@ static int dpaa2_dpio_probe(struct fsl_mc_device *dpio_dev)
>>    
>>    	dev_info(dev, "probed\n");
>>    	dev_dbg(dev, "   receives_notifications = %d\n",
>> -		desc.receives_notifications);
>> +		priv->desc.receives_notifications);
>>    	dpio_close(dpio_dev->mc_io, 0, dpio_dev->mc_handle);
>>    	fsl_mc_portal_free(dpio_dev->mc_io);
>>    
>> @@ -182,6 +191,10 @@ static int dpaa2_dpio_probe(struct fsl_mc_device *dpio_dev)
>>    err_register_dpio_irq:
>>    	fsl_mc_free_irqs(dpio_dev);
>>    err_allocate_irqs:
>> +	iounmap(priv->desc.regs_cinh);
>> +err_ioremap_failed:
>> +	memunmap(priv->desc.regs_cena);
> ...then you wouldn't need to worry about this.
>
>> +err_too_many_cpu:
>>    	dpio_disable(dpio_dev->mc_io, 0, dpio_dev->mc_handle);
>>    err_get_attr:
>>    	dpio_close(dpio_dev->mc_io, 0, dpio_dev->mc_handle);
>> @@ -189,6 +202,7 @@ static int dpaa2_dpio_probe(struct fsl_mc_device *dpio_dev)
>>    	fsl_mc_portal_free(dpio_dev->mc_io);
>>    err_mcportal:
>>    	dev_set_drvdata(dev, NULL);
>> +	devm_kfree(dev, priv);
> The whole point of devm_* is that you don't need to do this - the devres
> entries are freed automatically by the driver core upon probe failure or
> driver detach, i.e. priv was never leaking.
Right - Not sure what I was thinking yesterday. I think I saw the alloc 
without free and instinctively
added it.  I will remove this.
>
>>    err_priv_alloc:
>>    	return err;
>>    }
>> @@ -230,8 +244,13 @@ static int dpaa2_dpio_remove(struct fsl_mc_device *dpio_dev)
>>    
>>    	dpio_close(dpio_dev->mc_io, 0, dpio_dev->mc_handle);
>>    
>> +	iounmap(priv->desc.regs_cinh);
>> +	memunmap(priv->desc.regs_cena);
>> +
>>    	fsl_mc_portal_free(dpio_dev->mc_io);
>>    
>> +	devm_kfree(dev, priv);
>> +
>>    	dev_set_drvdata(dev, NULL);
> Note that clearing drvdata is something else the driver core already
> does at about the same time as cleaning up devres entries (see
> __device_release_driver() and the failure path of really_probe(), in
> drivers/base/dd.c), so this has been similarly superfluous all along.
Yes I'll clean this up too.  Thanks for the comments, this will make 
things better for sure.
>
> Robin.
>


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-03-27 13:19 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-26 19:05 [PATCH v3 0/4] drives/soc/fsl: Move DPIO driver out of staging Roy Pledge
2018-03-26 19:05 ` [PATCH v3 1/4] drivers/staging/fsl-mc: Use memremap for DPIO cache enabled area Roy Pledge
2018-03-26 19:05 ` [PATCH v3 2/4] drivers/staging/fsl-mc: Fix DPIO error path issues Roy Pledge
2018-03-27 11:05   ` Robin Murphy
2018-03-27 13:19     ` Roy Pledge
2018-03-26 19:05 ` [PATCH v3 3/4] staging:fsl-mc: Move DPIO from staging to drivers/soc/fsl Roy Pledge
2018-03-26 19:05 ` [PATCH v3 4/4] drivers/staging: Remove fsl-mc driver from staging Roy Pledge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).