linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] bus: fsl-mc: scattered updates
@ 2020-07-17 15:47 Ioana Ciornei
  2020-07-17 15:47 ` [PATCH 1/3] bus: fsl-mc: add missing device types Ioana Ciornei
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Ioana Ciornei @ 2020-07-17 15:47 UTC (permalink / raw)
  To: gregkh, linux-kernel; +Cc: laurentiu.tudor, Ioana Ciornei

This patch set adds some scattered updates to the fsl-mc bus: first we
add some missing device types that can be found on the bus, then there
is a change needed for the PREEMPT_RT variant and the probe order for the
newly added objects on the fsl-mc bus is changed so that allocatable
objects are probed at first since they are being used by any other
driver.

Grigore Popescu (1):
  bus: fsl-mc: probe the allocatable objects first

Ioana Ciornei (1):
  bus: fsl-mc: add missing device types

Laurentiu Tudor (1):
  bus: fsl-mc: use raw spin lock to serialize mc cmds

 drivers/bus/fsl-mc/dprc-driver.c | 57 ++++++++++++++++++++++----------
 drivers/bus/fsl-mc/fsl-mc-bus.c  | 30 +++++++++++++++++
 drivers/bus/fsl-mc/mc-io.c       |  2 +-
 drivers/bus/fsl-mc/mc-sys.c      |  4 +--
 include/linux/fsl/mc.h           | 32 +++++++++++++++++-
 5 files changed, 104 insertions(+), 21 deletions(-)

-- 
2.25.1


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

* [PATCH 1/3] bus: fsl-mc: add missing device types
  2020-07-17 15:47 [PATCH 0/3] bus: fsl-mc: scattered updates Ioana Ciornei
@ 2020-07-17 15:47 ` Ioana Ciornei
  2020-07-17 15:47 ` [PATCH 2/3] bus: fsl-mc: use raw spin lock to serialize mc cmds Ioana Ciornei
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Ioana Ciornei @ 2020-07-17 15:47 UTC (permalink / raw)
  To: gregkh, linux-kernel; +Cc: laurentiu.tudor, Ioana Ciornei

The MC bus has different types of devices that can be discovered on the
bus. Add the missing device types.

Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
 drivers/bus/fsl-mc/fsl-mc-bus.c | 30 ++++++++++++++++++++++++++++++
 include/linux/fsl/mc.h          | 30 ++++++++++++++++++++++++++++++
 2 files changed, 60 insertions(+)

diff --git a/drivers/bus/fsl-mc/fsl-mc-bus.c b/drivers/bus/fsl-mc/fsl-mc-bus.c
index 40526da5c6a6..ee1873438e97 100644
--- a/drivers/bus/fsl-mc/fsl-mc-bus.c
+++ b/drivers/bus/fsl-mc/fsl-mc-bus.c
@@ -201,6 +201,31 @@ struct device_type fsl_mc_bus_dpseci_type = {
 };
 EXPORT_SYMBOL_GPL(fsl_mc_bus_dpseci_type);
 
+struct device_type fsl_mc_bus_dpdmux_type = {
+	.name = "fsl_mc_bus_dpdmux"
+};
+EXPORT_SYMBOL_GPL(fsl_mc_bus_dpdmux_type);
+
+struct device_type fsl_mc_bus_dpdcei_type = {
+	.name = "fsl_mc_bus_dpdcei"
+};
+EXPORT_SYMBOL_GPL(fsl_mc_bus_dpdcei_type);
+
+struct device_type fsl_mc_bus_dpaiop_type = {
+	.name = "fsl_mc_bus_dpaiop"
+};
+EXPORT_SYMBOL_GPL(fsl_mc_bus_dpaiop_type);
+
+struct device_type fsl_mc_bus_dpci_type = {
+	.name = "fsl_mc_bus_dpci"
+};
+EXPORT_SYMBOL_GPL(fsl_mc_bus_dpci_type);
+
+struct device_type fsl_mc_bus_dpdmai_type = {
+	.name = "fsl_mc_bus_dpdmai"
+};
+EXPORT_SYMBOL_GPL(fsl_mc_bus_dpdmai_type);
+
 static struct device_type *fsl_mc_get_device_type(const char *type)
 {
 	static const struct {
@@ -217,6 +242,11 @@ static struct device_type *fsl_mc_get_device_type(const char *type)
 		{ &fsl_mc_bus_dpmac_type, "dpmac" },
 		{ &fsl_mc_bus_dprtc_type, "dprtc" },
 		{ &fsl_mc_bus_dpseci_type, "dpseci" },
+		{ &fsl_mc_bus_dpdmux_type, "dpdmux" },
+		{ &fsl_mc_bus_dpdcei_type, "dpdcei" },
+		{ &fsl_mc_bus_dpaiop_type, "dpaiop" },
+		{ &fsl_mc_bus_dpci_type, "dpci" },
+		{ &fsl_mc_bus_dpdmai_type, "dpdmai" },
 		{ NULL, NULL }
 	};
 	int i;
diff --git a/include/linux/fsl/mc.h b/include/linux/fsl/mc.h
index 2b5f8366dbe1..cdb03aca2aef 100644
--- a/include/linux/fsl/mc.h
+++ b/include/linux/fsl/mc.h
@@ -433,6 +433,11 @@ extern struct device_type fsl_mc_bus_dpmcp_type;
 extern struct device_type fsl_mc_bus_dpmac_type;
 extern struct device_type fsl_mc_bus_dprtc_type;
 extern struct device_type fsl_mc_bus_dpseci_type;
+extern struct device_type fsl_mc_bus_dpdmux_type;
+extern struct device_type fsl_mc_bus_dpdcei_type;
+extern struct device_type fsl_mc_bus_dpaiop_type;
+extern struct device_type fsl_mc_bus_dpci_type;
+extern struct device_type fsl_mc_bus_dpdmai_type;
 
 static inline bool is_fsl_mc_bus_dprc(const struct fsl_mc_device *mc_dev)
 {
@@ -454,6 +459,11 @@ static inline bool is_fsl_mc_bus_dpsw(const struct fsl_mc_device *mc_dev)
 	return mc_dev->dev.type == &fsl_mc_bus_dpsw_type;
 }
 
+static inline bool is_fsl_mc_bus_dpdmux(const struct fsl_mc_device *mc_dev)
+{
+	return mc_dev->dev.type == &fsl_mc_bus_dpdmux_type;
+}
+
 static inline bool is_fsl_mc_bus_dpbp(const struct fsl_mc_device *mc_dev)
 {
 	return mc_dev->dev.type == &fsl_mc_bus_dpbp_type;
@@ -484,6 +494,26 @@ static inline bool is_fsl_mc_bus_dpseci(const struct fsl_mc_device *mc_dev)
 	return mc_dev->dev.type == &fsl_mc_bus_dpseci_type;
 }
 
+static inline bool is_fsl_mc_bus_dpdcei(const struct fsl_mc_device *mc_dev)
+{
+	return mc_dev->dev.type == &fsl_mc_bus_dpdcei_type;
+}
+
+static inline bool is_fsl_mc_bus_dpaiop(const struct fsl_mc_device *mc_dev)
+{
+	return mc_dev->dev.type == &fsl_mc_bus_dpaiop_type;
+}
+
+static inline bool is_fsl_mc_bus_dpci(const struct fsl_mc_device *mc_dev)
+{
+	return mc_dev->dev.type == &fsl_mc_bus_dpci_type;
+}
+
+static inline bool is_fsl_mc_bus_dpdmai(const struct fsl_mc_device *mc_dev)
+{
+	return mc_dev->dev.type == &fsl_mc_bus_dpdmai_type;
+}
+
 /*
  * Data Path Buffer Pool (DPBP) API
  * Contains initialization APIs and runtime control APIs for DPBP
-- 
2.25.1


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

* [PATCH 2/3] bus: fsl-mc: use raw spin lock to serialize mc cmds
  2020-07-17 15:47 [PATCH 0/3] bus: fsl-mc: scattered updates Ioana Ciornei
  2020-07-17 15:47 ` [PATCH 1/3] bus: fsl-mc: add missing device types Ioana Ciornei
@ 2020-07-17 15:47 ` Ioana Ciornei
  2020-07-17 15:48 ` [PATCH 3/3] bus: fsl-mc: probe the allocatable objects first Ioana Ciornei
  2020-07-20  8:11 ` [PATCH 0/3] bus: fsl-mc: scattered updates Laurentiu Tudor
  3 siblings, 0 replies; 5+ messages in thread
From: Ioana Ciornei @ 2020-07-17 15:47 UTC (permalink / raw)
  To: gregkh, linux-kernel; +Cc: laurentiu.tudor, Ioana Ciornei

From: Laurentiu Tudor <laurentiu.tudor@nxp.com>

Replace the spinlock that serializes the MC commands with a raw
spinlock. This is needed for the RT kernel because there are MC
commands sent in interrupt context.

Signed-off-by: Laurentiu Tudor <laurentiu.tudor@nxp.com>
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
 drivers/bus/fsl-mc/mc-io.c  | 2 +-
 drivers/bus/fsl-mc/mc-sys.c | 4 ++--
 include/linux/fsl/mc.h      | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/bus/fsl-mc/mc-io.c b/drivers/bus/fsl-mc/mc-io.c
index 6ae48ad80409..a30b53f1d87d 100644
--- a/drivers/bus/fsl-mc/mc-io.c
+++ b/drivers/bus/fsl-mc/mc-io.c
@@ -82,7 +82,7 @@ int __must_check fsl_create_mc_io(struct device *dev,
 	mc_io->portal_phys_addr = mc_portal_phys_addr;
 	mc_io->portal_size = mc_portal_size;
 	if (flags & FSL_MC_IO_ATOMIC_CONTEXT_PORTAL)
-		spin_lock_init(&mc_io->spinlock);
+		raw_spin_lock_init(&mc_io->spinlock);
 	else
 		mutex_init(&mc_io->mutex);
 
diff --git a/drivers/bus/fsl-mc/mc-sys.c b/drivers/bus/fsl-mc/mc-sys.c
index 3221a7fbaf0a..85a0225db522 100644
--- a/drivers/bus/fsl-mc/mc-sys.c
+++ b/drivers/bus/fsl-mc/mc-sys.c
@@ -251,7 +251,7 @@ int mc_send_command(struct fsl_mc_io *mc_io, struct fsl_mc_command *cmd)
 		return -EINVAL;
 
 	if (mc_io->flags & FSL_MC_IO_ATOMIC_CONTEXT_PORTAL)
-		spin_lock_irqsave(&mc_io->spinlock, irq_flags);
+		raw_spin_lock_irqsave(&mc_io->spinlock, irq_flags);
 	else
 		mutex_lock(&mc_io->mutex);
 
@@ -287,7 +287,7 @@ int mc_send_command(struct fsl_mc_io *mc_io, struct fsl_mc_command *cmd)
 	error = 0;
 common_exit:
 	if (mc_io->flags & FSL_MC_IO_ATOMIC_CONTEXT_PORTAL)
-		spin_unlock_irqrestore(&mc_io->spinlock, irq_flags);
+		raw_spin_unlock_irqrestore(&mc_io->spinlock, irq_flags);
 	else
 		mutex_unlock(&mc_io->mutex);
 
diff --git a/include/linux/fsl/mc.h b/include/linux/fsl/mc.h
index cdb03aca2aef..a428c61ead6e 100644
--- a/include/linux/fsl/mc.h
+++ b/include/linux/fsl/mc.h
@@ -339,7 +339,7 @@ struct fsl_mc_io {
 		 * This field is only meaningful if the
 		 * FSL_MC_IO_ATOMIC_CONTEXT_PORTAL flag is set
 		 */
-		spinlock_t spinlock;	/* serializes mc_send_command() */
+		raw_spinlock_t spinlock; /* serializes mc_send_command() */
 	};
 };
 
-- 
2.25.1


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

* [PATCH 3/3] bus: fsl-mc: probe the allocatable objects first
  2020-07-17 15:47 [PATCH 0/3] bus: fsl-mc: scattered updates Ioana Ciornei
  2020-07-17 15:47 ` [PATCH 1/3] bus: fsl-mc: add missing device types Ioana Ciornei
  2020-07-17 15:47 ` [PATCH 2/3] bus: fsl-mc: use raw spin lock to serialize mc cmds Ioana Ciornei
@ 2020-07-17 15:48 ` Ioana Ciornei
  2020-07-20  8:11 ` [PATCH 0/3] bus: fsl-mc: scattered updates Laurentiu Tudor
  3 siblings, 0 replies; 5+ messages in thread
From: Ioana Ciornei @ 2020-07-17 15:48 UTC (permalink / raw)
  To: gregkh, linux-kernel; +Cc: laurentiu.tudor, Grigore Popescu, Ioana Ciornei

From: Grigore Popescu <grigore.popescu@nxp.com>

Because the DPNIs are probed before DPMCPs and other objects that need
to be allocated, messages like "No more resources of type X left" are
printed by the fsl-mc bus driver. This patch resolves the issue by probing
the allocatable objects first and then any other object that may use
them.

Signed-off-by: Grigore Popescu <grigore.popescu@nxp.com>
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
 drivers/bus/fsl-mc/dprc-driver.c | 57 ++++++++++++++++++++++----------
 1 file changed, 40 insertions(+), 17 deletions(-)

diff --git a/drivers/bus/fsl-mc/dprc-driver.c b/drivers/bus/fsl-mc/dprc-driver.c
index c8b1c3842c1a..3512d1b95821 100644
--- a/drivers/bus/fsl-mc/dprc-driver.c
+++ b/drivers/bus/fsl-mc/dprc-driver.c
@@ -27,7 +27,16 @@ static bool fsl_mc_device_match(struct fsl_mc_device *mc_dev,
 {
 	return mc_dev->obj_desc.id == obj_desc->id &&
 	       strcmp(mc_dev->obj_desc.type, obj_desc->type) == 0;
+}
 
+static bool fsl_mc_obj_desc_is_allocatable(struct fsl_mc_obj_desc *obj)
+{
+	if (strcmp(obj->type, "dpmcp") == 0 ||
+	    strcmp(obj->type, "dpcon") == 0 ||
+	    strcmp(obj->type, "dpbp") == 0)
+		return true;
+	else
+		return false;
 }
 
 static int __fsl_mc_device_remove_if_not_in_mc(struct device *dev, void *data)
@@ -150,6 +159,27 @@ static void check_plugged_state_change(struct fsl_mc_device *mc_dev,
 	}
 }
 
+static void fsl_mc_obj_device_add(struct fsl_mc_device *mc_bus_dev,
+				  struct fsl_mc_obj_desc *obj_desc)
+{
+	int error;
+	struct fsl_mc_device *child_dev;
+
+	/*
+	 * Check if device is already known to Linux:
+	 */
+	child_dev = fsl_mc_device_lookup(obj_desc, mc_bus_dev);
+	if (child_dev) {
+		check_plugged_state_change(child_dev, obj_desc);
+		put_device(&child_dev->dev);
+	} else {
+		error = fsl_mc_device_add(obj_desc, NULL, &mc_bus_dev->dev,
+					  &child_dev);
+		if (error < 0)
+			return;
+	}
+}
+
 /**
  * dprc_add_new_devices - Adds devices to the logical bus for a DPRC
  *
@@ -166,30 +196,23 @@ static void dprc_add_new_devices(struct fsl_mc_device *mc_bus_dev,
 				 struct fsl_mc_obj_desc *obj_desc_array,
 				 int num_child_objects_in_mc)
 {
-	int error;
 	int i;
 
+	/* probe the allocable objects first */
 	for (i = 0; i < num_child_objects_in_mc; i++) {
-		struct fsl_mc_device *child_dev;
 		struct fsl_mc_obj_desc *obj_desc = &obj_desc_array[i];
 
-		if (strlen(obj_desc->type) == 0)
-			continue;
+		if (strlen(obj_desc->type) > 0 &&
+		    fsl_mc_obj_desc_is_allocatable(obj_desc))
+			fsl_mc_obj_device_add(mc_bus_dev, obj_desc);
+	}
 
-		/*
-		 * Check if device is already known to Linux:
-		 */
-		child_dev = fsl_mc_device_lookup(obj_desc, mc_bus_dev);
-		if (child_dev) {
-			check_plugged_state_change(child_dev, obj_desc);
-			put_device(&child_dev->dev);
-			continue;
-		}
+	for (i = 0; i < num_child_objects_in_mc; i++) {
+		struct fsl_mc_obj_desc *obj_desc = &obj_desc_array[i];
 
-		error = fsl_mc_device_add(obj_desc, NULL, &mc_bus_dev->dev,
-					  &child_dev);
-		if (error < 0)
-			continue;
+		if (strlen(obj_desc->type) > 0 &&
+		    !fsl_mc_obj_desc_is_allocatable(obj_desc))
+			fsl_mc_obj_device_add(mc_bus_dev, obj_desc);
 	}
 }
 
-- 
2.25.1


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

* Re: [PATCH 0/3] bus: fsl-mc: scattered updates
  2020-07-17 15:47 [PATCH 0/3] bus: fsl-mc: scattered updates Ioana Ciornei
                   ` (2 preceding siblings ...)
  2020-07-17 15:48 ` [PATCH 3/3] bus: fsl-mc: probe the allocatable objects first Ioana Ciornei
@ 2020-07-20  8:11 ` Laurentiu Tudor
  3 siblings, 0 replies; 5+ messages in thread
From: Laurentiu Tudor @ 2020-07-20  8:11 UTC (permalink / raw)
  To: Ioana Ciornei, gregkh, linux-kernel



On 7/17/2020 6:47 PM, Ioana Ciornei wrote:
> This patch set adds some scattered updates to the fsl-mc bus: first we
> add some missing device types that can be found on the bus, then there
> is a change needed for the PREEMPT_RT variant and the probe order for the
> newly added objects on the fsl-mc bus is changed so that allocatable
> objects are probed at first since they are being used by any other
> driver.
> 
> Grigore Popescu (1):
>   bus: fsl-mc: probe the allocatable objects first
> 
> Ioana Ciornei (1):
>   bus: fsl-mc: add missing device types
> 
> Laurentiu Tudor (1):
>   bus: fsl-mc: use raw spin lock to serialize mc cmds
> 
>  drivers/bus/fsl-mc/dprc-driver.c | 57 ++++++++++++++++++++++----------
>  drivers/bus/fsl-mc/fsl-mc-bus.c  | 30 +++++++++++++++++
>  drivers/bus/fsl-mc/mc-io.c       |  2 +-
>  drivers/bus/fsl-mc/mc-sys.c      |  4 +--
>  include/linux/fsl/mc.h           | 32 +++++++++++++++++-
>  5 files changed, 104 insertions(+), 21 deletions(-)
> 

For the series:

Reviewed-by: Laurentiu Tudor <laurentiu.tudor@nxp.com>

---
Best Regards, Laurentiu

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

end of thread, other threads:[~2020-07-20  8:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-17 15:47 [PATCH 0/3] bus: fsl-mc: scattered updates Ioana Ciornei
2020-07-17 15:47 ` [PATCH 1/3] bus: fsl-mc: add missing device types Ioana Ciornei
2020-07-17 15:47 ` [PATCH 2/3] bus: fsl-mc: use raw spin lock to serialize mc cmds Ioana Ciornei
2020-07-17 15:48 ` [PATCH 3/3] bus: fsl-mc: probe the allocatable objects first Ioana Ciornei
2020-07-20  8:11 ` [PATCH 0/3] bus: fsl-mc: scattered updates Laurentiu Tudor

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).