aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/fsl-mc/include
diff options
context:
space:
mode:
authorJ. German Rivera <German.Rivera@freescale.com>2015-10-17 15:33:15 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-10-17 20:54:46 -0700
commit63f2be5c3b358db031f86eafa9cd450f6558a55b (patch)
tree26e710dc8423681051d12f897ebc7a1b025ca4fb /drivers/staging/fsl-mc/include
parentstaging: fsl-mc:Added support for atomic portals (diff)
downloadlinux-dev-63f2be5c3b358db031f86eafa9cd450f6558a55b.tar.xz
linux-dev-63f2be5c3b358db031f86eafa9cd450f6558a55b.zip
staging: fsl-mc: Added serialization to mc_send_command()
When the same portal is used to call mc_send_command() from two different threads or a thread and an interrupt handler, serialization is required, as the MC only supports one outstanding command per MC portal. Thus, a new command should not be sent to the MC until the last command sent has been responded by the MC. Signed-off-by: J. German Rivera <German.Rivera@freescale.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/fsl-mc/include')
-rw-r--r--drivers/staging/fsl-mc/include/mc-sys.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/drivers/staging/fsl-mc/include/mc-sys.h b/drivers/staging/fsl-mc/include/mc-sys.h
index 15e19af31115..c5038cc77240 100644
--- a/drivers/staging/fsl-mc/include/mc-sys.h
+++ b/drivers/staging/fsl-mc/include/mc-sys.h
@@ -39,6 +39,8 @@
#include <linux/errno.h>
#include <linux/io.h>
#include <linux/dma-mapping.h>
+#include <linux/mutex.h>
+#include <linux/spinlock.h>
/**
* Bit masks for a MC I/O object (struct fsl_mc_io) flags
@@ -56,6 +58,20 @@ struct mc_command;
* @portal_phys_addr: MC command portal physical address
* @portal_virt_addr: MC command portal virtual address
* @dpmcp_dev: pointer to the DPMCP device associated with the MC portal.
+ *
+ * Fields are only meaningful if the FSL_MC_IO_ATOMIC_CONTEXT_PORTAL flag is not
+ * set:
+ * @mutex: Mutex to serialize mc_send_command() calls that use the same MC
+ * portal, if the fsl_mc_io object was created with the
+ * FSL_MC_IO_ATOMIC_CONTEXT_PORTAL flag off. mc_send_command() calls for this
+ * fsl_mc_io object must be made only from non-atomic context.
+ *
+ * Fields are only meaningful if the FSL_MC_IO_ATOMIC_CONTEXT_PORTAL flag is
+ * set:
+ * @spinlock: Spinlock to serialize mc_send_command() calls that use the same MC
+ * portal, if the fsl_mc_io object was created with the
+ * FSL_MC_IO_ATOMIC_CONTEXT_PORTAL flag on. mc_send_command() calls for this
+ * fsl_mc_io object can be made from atomic or non-atomic context.
*/
struct fsl_mc_io {
struct device *dev;
@@ -64,6 +80,19 @@ struct fsl_mc_io {
phys_addr_t portal_phys_addr;
void __iomem *portal_virt_addr;
struct fsl_mc_device *dpmcp_dev;
+ union {
+ /*
+ * This field is only meaningful if the
+ * FSL_MC_IO_ATOMIC_CONTEXT_PORTAL flag is not set
+ */
+ struct mutex mutex; /* serializes mc_send_command() */
+
+ /*
+ * This field is only meaningful if the
+ * FSL_MC_IO_ATOMIC_CONTEXT_PORTAL flag is set
+ */
+ spinlock_t spinlock; /* serializes mc_send_command() */
+ };
};
int __must_check fsl_create_mc_io(struct device *dev,