Skip to contentSkip to conversation

remoteproc: k3: Include what we need and only what we need

PATCH In review Andrew Davis 3 participants 9 messages Sep 4 – Sep 15 Remote processor (remoteproc)

lore
Share & tools
lore
#1 lore raw

PATCH 2/3 remoteproc: k3-dsp: Fix usage of omap_mbox_message and mbox_msg_t

In reply to Andrew Davis

The type of message sent using omap-mailbox is always u32. The definition of mbox_msg_t is uintptr_t which is wrong as that type changes based on the architecture (32bit vs 64bit). Make the type fixed to u32.

This then means we need to fix the helper macro omap_mbox_message so it doesn't cast to u32 twice. What this macro should be doing is converting from the message type returned from the mailbox framework into the omap-mailbox type. When fixing this we should add a macro for the other direction (from omap-mailbox type to something that can be used with mbox_send_message).

After these changes, make use of the new macros as appropriate.

---
 drivers/remoteproc/omap_remoteproc.c | 10 +++++-----
 drivers/remoteproc/ti_k3_common.c    | 10 ++--------
 include/linux/omap-mailbox.h         |  5 +++--
 3 files changed, 10 insertions(+), 15 deletions(-)
drivers/remoteproc/omap_remoteproc.c +5 -5
index 6ed0f28edac9c..efff95b8e363f 100644
@@ -499,7 +499,7 @@ static void omap_rproc_mbox_callback(struct mbox_client *client, void *data)
 						client);
 	struct device *dev = oproc->rproc->dev.parent;
 	const char *name = oproc->rproc->name;
-	u32 msg = (u32)data;
+	mbox_msg_t msg = omap_mbox_from_message(data);
 
 	dev_dbg(dev, "mbox msg: 0x%x\n", msg);
 
@@ -550,7 +550,7 @@ static void omap_rproc_kick(struct rproc *rproc, int vqid)
 	}
 
 	/* send the index of the triggered virtqueue in the mailbox payload */
-	ret = mbox_send_message(oproc->mbox, (void *)vqid);
+	ret = mbox_send_message(oproc->mbox, omap_mbox_to_message(vqid));
 	if (ret < 0)
 		dev_err(dev, "failed to send mailbox message, status = %d\n",
 			ret);
@@ -628,7 +628,7 @@ static int omap_rproc_start(struct rproc *rproc)
 	 * Note that the reply will _not_ arrive immediately: this message
 	 * will wait in the mailbox fifo until the remote processor is booted.
 	 */
-	ret = mbox_send_message(oproc->mbox, (void *)RP_MBOX_ECHO_REQUEST);
+	ret = mbox_send_message(oproc->mbox, omap_mbox_to_message(RP_MBOX_ECHO_REQUEST));
 	if (ret < 0) {
 		dev_err(dev, "mbox_send_message failed: %d\n", ret);
 		goto put_mbox;
@@ -777,13 +777,13 @@ static int _omap_rproc_suspend(struct rproc *rproc, bool auto_suspend)
 	struct omap_rproc *oproc = rproc->priv;
 	unsigned long to = msecs_to_jiffies(DEF_SUSPEND_TIMEOUT);
 	unsigned long ta = jiffies + to;
-	u32 suspend_msg = auto_suspend ?
+	mbox_msg_t suspend_msg = auto_suspend ?
 				RP_MBOX_SUSPEND_AUTO : RP_MBOX_SUSPEND_SYSTEM;
 	int ret;
 
 	reinit_completion(&oproc->pm_comp);
 	oproc->suspend_acked = false;
-	ret = mbox_send_message(oproc->mbox, (void *)suspend_msg);
+	ret = mbox_send_message(oproc->mbox, omap_mbox_to_message(suspend_msg));
 	if (ret < 0) {
 		dev_err(dev, "PM mbox_send_message failed: %d\n", ret);
 		return ret;
drivers/remoteproc/ti_k3_common.c +2 -8
index 3cb8ae5d72f67..4b6da3363f6c2 100644
@@ -54,7 +54,7 @@ void k3_rproc_mbox_callback(struct mbox_client *client, void *data)
 	struct k3_rproc *kproc = container_of(client, struct k3_rproc, client);
 	struct device *dev = kproc->rproc->dev.parent;
 	struct rproc *rproc = kproc->rproc;
-	u32 msg = (u32)(uintptr_t)(data);
+	mbox_msg_t msg = omap_mbox_from_message(data);
 
 	dev_dbg(dev, "mbox msg: 0x%x\n", msg);
 
@@ -94,15 +94,9 @@ void k3_rproc_kick(struct rproc *rproc, int vqid)
 {
 	struct k3_rproc *kproc = rproc->priv;
 	struct device *dev = kproc->dev;
-	u32 msg = (u32)vqid;
 	int ret;
 
-	/*
-	 * Send the index of the triggered virtqueue in the mailbox payload.
-	 * NOTE: msg is cast to uintptr_t to prevent compiler warnings when
-	 * void* is 64bit. It is safely cast back to u32 in the mailbox driver.
-	 */
-	ret = mbox_send_message(kproc->mbox, (void *)(uintptr_t)msg);
+	ret = mbox_send_message(kproc->mbox, omap_mbox_to_message(vqid));
 	if (ret < 0)
 		dev_err(dev, "failed to send mailbox message, status = %d\n",
 			ret);
include/linux/omap-mailbox.h +3 -2
index 3cc5c4ed7f5a6..e45f8c3841c23 100644
@@ -6,8 +6,9 @@
 #ifndef OMAP_MAILBOX_H
 #define OMAP_MAILBOX_H
 
-typedef uintptr_t mbox_msg_t;
+typedef u32 mbox_msg_t;
 
-#define omap_mbox_message(data) (u32)(mbox_msg_t)(data)
+#define omap_mbox_to_message(data) ((void *)(uintptr_t)(data))
+#define omap_mbox_from_message(data) ((mbox_msg_t)(uintptr_t)(data))
 
 #endif /* OMAP_MAILBOX_H */
Signature · 1 line
2.39.2
#5 lore raw

PATCH 3/3 remoteproc: Add compile testing for additional TI drivers

In reply to Andrew Davis

Many Remoteproc drivers, including K3, can and are built for compile testing. The WKUP_M3, Keystone, and DA8xx can be also, enable this here.

Doing this exposes a compile warning on 64bit platforms as size_t changes size, use the correct printf format specifier for size_t.

We cannot compile test for OMAP_REMOTEPROC due to dependency on OMAP clock framework. But while here fix up the Kconfig help text which claims this driver only works for OMAP4, when it really works across several OMAP-class devices.

---
 drivers/remoteproc/Kconfig           | 10 ++++------
 drivers/remoteproc/omap_remoteproc.c |  2 +-
 2 files changed, 5 insertions(+), 7 deletions(-)
drivers/remoteproc/Kconfig +4 -6
index 5b56b2dcc725f..73500fdc227db 100644
@@ -83,9 +83,7 @@ config OMAP_REMOTEPROC
 	select OMAP2PLUS_MBOX
 	help
 	  Say y here to support OMAP's remote processors (dual M3
-	  and DSP on OMAP4) via the remote processor framework.
-
-	  Currently only supported on OMAP4.
+	  and DSP) via the remote processor framework.
 
 	  Usually you want to say Y here, in order to enable multimedia
 	  use-cases to run on your platform (multimedia codecs are
@@ -108,7 +106,7 @@ config OMAP_REMOTEPROC_WATCHDOG
 
 config WKUP_M3_RPROC
 	tristate "AMx3xx Wakeup M3 remoteproc support"
-	depends on SOC_AM33XX || SOC_AM43XX
+	depends on SOC_AM33XX || SOC_AM43XX || COMPILE_TEST
 	help
 	  Say y here to support Wakeup M3 remote processor on TI AM33xx
 	  and AM43xx family of SoCs.
@@ -120,7 +118,7 @@ config WKUP_M3_RPROC
 
 config DA8XX_REMOTEPROC
 	tristate "DA8xx/OMAP-L13x remoteproc support"
-	depends on ARCH_DAVINCI_DA8XX
+	depends on ARCH_DAVINCI_DA8XX || COMPILE_TEST
 	depends on DMA_CMA
 	help
 	  Say y here to support DA8xx/OMAP-L13x remote processors via the
@@ -141,7 +139,7 @@ config DA8XX_REMOTEPROC
 
 config KEYSTONE_REMOTEPROC
 	tristate "Keystone Remoteproc support"
-	depends on ARCH_KEYSTONE
+	depends on ARCH_KEYSTONE || COMPILE_TEST
 	help
 	  Say Y here here to support Keystone remote processors (DSP)
 	  via the remote processor framework.
drivers/remoteproc/omap_remoteproc.c +1 -1
index efff95b8e363f..1e96506ce7ca7 100644
@@ -1208,7 +1208,7 @@ static int omap_rproc_of_get_internal_memories(struct platform_device *pdev,
 		oproc->mem[i].dev_addr = data->mems[i].dev_addr;
 		oproc->mem[i].size = resource_size(res);
 
-		dev_dbg(dev, "memory %8s: bus addr %pa size 0x%x va %p da 0x%x\n",
+		dev_dbg(dev, "memory %8s: bus addr %pa size 0x%zx va %p da 0x%x\n",
 			data->mems[i].name, &oproc->mem[i].bus_addr,
 			oproc->mem[i].size, oproc->mem[i].cpu_addr,
 			oproc->mem[i].dev_addr);
Signature · 1 line
2.39.2
#0 lore raw

PATCH 1/3 remoteproc: k3: Include what we need and only what we need

The header ti_k3_common.h uses several definitions in headers it does not include itself, this makes users of this header responsible for including the right headers first. Instead include what we need here. Then go and remove some headers that we do not use from the K3 Remoteproc drivers.

---
 drivers/remoteproc/ti_k3_common.h         | 4 ++++
 drivers/remoteproc/ti_k3_dsp_remoteproc.c | 3 ---
 drivers/remoteproc/ti_k3_m4_remoteproc.c  | 4 +---
 drivers/remoteproc/ti_k3_r5_remoteproc.c  | 5 -----
 4 files changed, 5 insertions(+), 11 deletions(-)
drivers/remoteproc/ti_k3_common.h +4 -0
index aee3c28dbe510..c8430e42225fe 100644
@@ -21,6 +21,10 @@
 #ifndef REMOTEPROC_TI_K3_COMMON_H
 #define REMOTEPROC_TI_K3_COMMON_H
 
+#include <linux/mailbox_client.h>
+#include <linux/platform_device.h>
+#include <linux/types.h>
+
 #define KEYSTONE_RPROC_LOCAL_ADDRESS_MASK	(SZ_16M - 1)
 
 /**
drivers/remoteproc/ti_k3_dsp_remoteproc.c +0 -3
index d6ceea6dc920e..c916a86bc8294 100644
@@ -7,11 +7,8 @@
  */
 
 #include <linux/io.h>
-#include <linux/mailbox_client.h>
 #include <linux/module.h>
 #include <linux/of.h>
-#include <linux/of_reserved_mem.h>
-#include <linux/omap-mailbox.h>
 #include <linux/platform_device.h>
 #include <linux/remoteproc.h>
 #include <linux/reset.h>
drivers/remoteproc/ti_k3_m4_remoteproc.c +1 -3
index 3a11fd24eb52b..4c46f4a256a92 100644
@@ -7,10 +7,8 @@
  */
 
 #include <linux/io.h>
-#include <linux/mailbox_client.h>
 #include <linux/module.h>
-#include <linux/of_address.h>
-#include <linux/of_reserved_mem.h>
+#include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/remoteproc.h>
 #include <linux/reset.h>
drivers/remoteproc/ti_k3_r5_remoteproc.c +0 -5
index b1d04d082e44c..404acc1a9bb7c 100644
@@ -6,17 +6,12 @@
  *	Suman Anna <[email protected]>
  */
 
-#include <linux/dma-mapping.h>
 #include <linux/err.h>
 #include <linux/interrupt.h>
-#include <linux/kernel.h>
-#include <linux/mailbox_client.h>
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
-#include <linux/of_reserved_mem.h>
 #include <linux/of_platform.h>
-#include <linux/omap-mailbox.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
 #include <linux/remoteproc.h>
Signature · 1 line
2.39.2
maintainer
#2 lore raw

Re: [PATCH 2/3] remoteproc: k3-dsp: Fix usage of omap_mbox_message and mbox_msg_t

In reply to Andrew Davis
Quoted 26 lines · Andrew Davis

The type of message sent using omap-mailbox is always u32. The definition of mbox_msg_t is uintptr_t which is wrong as that type changes based on the architecture (32bit vs 64bit). Make the type fixed to u32.

This then means we need to fix the helper macro omap_mbox_message so it doesn't cast to u32 twice. What this macro should be doing is converting from the message type returned from the mailbox framework into the omap-mailbox type. When fixing this we should add a macro for the other direction (from omap-mailbox type to something that can be used with mbox_send_message).

After these changes, make use of the new macros as appropriate.

---
 drivers/remoteproc/omap_remoteproc.c | 10 +++++-----
 drivers/remoteproc/ti_k3_common.c    | 10 ++--------
 include/linux/omap-mailbox.h         |  5 +++--
 3 files changed, 10 insertions(+), 15 deletions(-)
drivers/remoteproc/omap_remoteproc.c +0 -0
index 6ed0f28edac9c..efff95b8e363f 100644

drivers/remoteproc/omap_remoteproc.c static void omap_rproc_mbox_callback(struct mbox_client *client, void *data) · line 503

Quoted 6 lines
drivers/remoteproc/omap_remoteproc.c +1 -1
@@ -499,7 +499,7 @@ static void omap_rproc_mbox_callback(struct mbox_client *client, void *data)
                                                client);
        struct device *dev = oproc->rproc->dev.parent;
        const char *name = oproc->rproc->name;
-       u32 msg = (u32)data;
+       mbox_msg_t msg = omap_mbox_from_message(data);
 

This patch looks familiar - was it submitted before but not merged?

I'm fine with this set but would like an RB/TB from someone else at TI (for all 3 patches).

Thanks,
Mathieu

Quoted 85 lines
drivers/remoteproc/omap_remoteproc.c +4 -4
        dev_dbg(dev, "mbox msg: 0x%x\n", msg);
 
@@ -550,7 +550,7 @@ static void omap_rproc_kick(struct rproc *rproc, int vqid)
        }
 
        /* send the index of the triggered virtqueue in the mailbox payload */
-       ret = mbox_send_message(oproc->mbox, (void *)vqid);
+       ret = mbox_send_message(oproc->mbox, omap_mbox_to_message(vqid));
        if (ret < 0)
                dev_err(dev, "failed to send mailbox message, status = %d\n",
                        ret);
@@ -628,7 +628,7 @@ static int omap_rproc_start(struct rproc *rproc)
         * Note that the reply will _not_ arrive immediately: this message
         * will wait in the mailbox fifo until the remote processor is booted.
         */
-       ret = mbox_send_message(oproc->mbox, (void *)RP_MBOX_ECHO_REQUEST);
+       ret = mbox_send_message(oproc->mbox, omap_mbox_to_message(RP_MBOX_ECHO_REQUEST));
        if (ret < 0) {
                dev_err(dev, "mbox_send_message failed: %d\n", ret);
                goto put_mbox;
@@ -777,13 +777,13 @@ static int _omap_rproc_suspend(struct rproc *rproc, bool auto_suspend)
        struct omap_rproc *oproc = rproc->priv;
        unsigned long to = msecs_to_jiffies(DEF_SUSPEND_TIMEOUT);
        unsigned long ta = jiffies + to;
-       u32 suspend_msg = auto_suspend ?
+       mbox_msg_t suspend_msg = auto_suspend ?
                                RP_MBOX_SUSPEND_AUTO : RP_MBOX_SUSPEND_SYSTEM;
        int ret;
 
        reinit_completion(&oproc->pm_comp);
        oproc->suspend_acked = false;
-       ret = mbox_send_message(oproc->mbox, (void *)suspend_msg);
+       ret = mbox_send_message(oproc->mbox, omap_mbox_to_message(suspend_msg));
        if (ret < 0) {
                dev_err(dev, "PM mbox_send_message failed: %d\n", ret);
                return ret;
drivers/remoteproc/ti_k3_common.c +2 -8
index 3cb8ae5d72f67..4b6da3363f6c2 100644
@@ -54,7 +54,7 @@ void k3_rproc_mbox_callback(struct mbox_client *client, void *data)
        struct k3_rproc *kproc = container_of(client, struct k3_rproc, client);
        struct device *dev = kproc->rproc->dev.parent;
        struct rproc *rproc = kproc->rproc;
-       u32 msg = (u32)(uintptr_t)(data);
+       mbox_msg_t msg = omap_mbox_from_message(data);
 
        dev_dbg(dev, "mbox msg: 0x%x\n", msg);
 
@@ -94,15 +94,9 @@ void k3_rproc_kick(struct rproc *rproc, int vqid)
 {
        struct k3_rproc *kproc = rproc->priv;
        struct device *dev = kproc->dev;
-       u32 msg = (u32)vqid;
        int ret;
 
-       /*
-        * Send the index of the triggered virtqueue in the mailbox payload.
-        * NOTE: msg is cast to uintptr_t to prevent compiler warnings when
-        * void* is 64bit. It is safely cast back to u32 in the mailbox driver.
-        */
-       ret = mbox_send_message(kproc->mbox, (void *)(uintptr_t)msg);
+       ret = mbox_send_message(kproc->mbox, omap_mbox_to_message(vqid));
        if (ret < 0)
                dev_err(dev, "failed to send mailbox message, status = %d\n",
                        ret);
include/linux/omap-mailbox.h +3 -3
index 3cc5c4ed7f5a6..e45f8c3841c23 100644
@@ -6,8 +6,9 @@
 #ifndef OMAP_MAILBOX_H
 #define OMAP_MAILBOX_H
 
-typedef uintptr_t mbox_msg_t;
+typedef u32 mbox_msg_t;
 
-#define omap_mbox_message(data) (u32)(mbox_msg_t)(data)
+#define omap_mbox_to_message(data) ((void *)(uintptr_t)(data))
+#define omap_mbox_from_message(data) ((mbox_msg_t)(uintptr_t)(data))
 
 #endif /* OMAP_MAILBOX_H */
--

2.39.2

#3 lore raw

Re: [PATCH 2/3] remoteproc: k3-dsp: Fix usage of omap_mbox_message and mbox_msg_t

Quoted 22 lines · Mathieu Poirier
Quoted 21 lines · Andrew Davis

The type of message sent using omap-mailbox is always u32. The definition of mbox_msg_t is uintptr_t which is wrong as that type changes based on the architecture (32bit vs 64bit). Make the type fixed to u32.

This then means we need to fix the helper macro omap_mbox_message so it doesn't cast to u32 twice. What this macro should be doing is converting from the message type returned from the mailbox framework into the omap-mailbox type. When fixing this we should add a macro for the other direction (from omap-mailbox type to something that can be used with mbox_send_message).

After these changes, make use of the new macros as appropriate.

---
  drivers/remoteproc/omap_remoteproc.c | 10 +++++-----
  drivers/remoteproc/ti_k3_common.c    | 10 ++--------
  include/linux/omap-mailbox.h         |  5 +++--
  3 files changed, 10 insertions(+), 15 deletions(-)
Quoted 14 lines

drivers/remoteproc/omap_remoteproc.c static void omap_rproc_mbox_callback(struct mbox_client *client, void *data) · line 503

Quoted 11 lines
drivers/remoteproc/omap_remoteproc.c +1 -1
index 6ed0f28edac9c..efff95b8e363f 100644
@@ -499,7 +499,7 @@ static void omap_rproc_mbox_callback(struct mbox_client *client, void *data)
                                                 client);
         struct device *dev = oproc->rproc->dev.parent;
         const char *name = oproc->rproc->name;
-       u32 msg = (u32)data;
+       mbox_msg_t msg = omap_mbox_from_message(data);
 

This patch looks familiar - was it submitted before but not merged?

Checking the archives I see I sent a patch a couple years back that removed the omap-mailbox.h header as it wasn't really used anywhere. This patch kinda goes the other way and fixes the header so it has some use.

Quoted 3 lines

I'm fine with this set but would like an RB/TB from someone else at TI (for all 3 patches).

Sure, let me see if I can get someone else here to independently test this and report back on list.

Thanks,
Andrew

Quoted 88 lines

Thanks,
Mathieu

Quoted 85 lines
drivers/remoteproc/omap_remoteproc.c +4 -4
         dev_dbg(dev, "mbox msg: 0x%x\n", msg);
 
@@ -550,7 +550,7 @@ static void omap_rproc_kick(struct rproc *rproc, int vqid)
         }
 
         /* send the index of the triggered virtqueue in the mailbox payload */
-       ret = mbox_send_message(oproc->mbox, (void *)vqid);
+       ret = mbox_send_message(oproc->mbox, omap_mbox_to_message(vqid));
         if (ret < 0)
                 dev_err(dev, "failed to send mailbox message, status = %d\n",
                         ret);
@@ -628,7 +628,7 @@ static int omap_rproc_start(struct rproc *rproc)
          * Note that the reply will _not_ arrive immediately: this message
          * will wait in the mailbox fifo until the remote processor is booted.
          */
-       ret = mbox_send_message(oproc->mbox, (void *)RP_MBOX_ECHO_REQUEST);
+       ret = mbox_send_message(oproc->mbox, omap_mbox_to_message(RP_MBOX_ECHO_REQUEST));
         if (ret < 0) {
                 dev_err(dev, "mbox_send_message failed: %d\n", ret);
                 goto put_mbox;
@@ -777,13 +777,13 @@ static int _omap_rproc_suspend(struct rproc *rproc, bool auto_suspend)
         struct omap_rproc *oproc = rproc->priv;
         unsigned long to = msecs_to_jiffies(DEF_SUSPEND_TIMEOUT);
         unsigned long ta = jiffies + to;
-       u32 suspend_msg = auto_suspend ?
+       mbox_msg_t suspend_msg = auto_suspend ?
                                 RP_MBOX_SUSPEND_AUTO : RP_MBOX_SUSPEND_SYSTEM;
         int ret;
 
         reinit_completion(&oproc->pm_comp);
         oproc->suspend_acked = false;
-       ret = mbox_send_message(oproc->mbox, (void *)suspend_msg);
+       ret = mbox_send_message(oproc->mbox, omap_mbox_to_message(suspend_msg));
         if (ret < 0) {
                 dev_err(dev, "PM mbox_send_message failed: %d\n", ret);
                 return ret;
drivers/remoteproc/ti_k3_common.c +2 -8
index 3cb8ae5d72f67..4b6da3363f6c2 100644
@@ -54,7 +54,7 @@ void k3_rproc_mbox_callback(struct mbox_client *client, void *data)
         struct k3_rproc *kproc = container_of(client, struct k3_rproc, client);
         struct device *dev = kproc->rproc->dev.parent;
         struct rproc *rproc = kproc->rproc;
-       u32 msg = (u32)(uintptr_t)(data);
+       mbox_msg_t msg = omap_mbox_from_message(data);
 
         dev_dbg(dev, "mbox msg: 0x%x\n", msg);
 
@@ -94,15 +94,9 @@ void k3_rproc_kick(struct rproc *rproc, int vqid)
  {
         struct k3_rproc *kproc = rproc->priv;
         struct device *dev = kproc->dev;
-       u32 msg = (u32)vqid;
         int ret;
 
-       /*
-        * Send the index of the triggered virtqueue in the mailbox payload.
-        * NOTE: msg is cast to uintptr_t to prevent compiler warnings when
-        * void* is 64bit. It is safely cast back to u32 in the mailbox driver.
-        */
-       ret = mbox_send_message(kproc->mbox, (void *)(uintptr_t)msg);
+       ret = mbox_send_message(kproc->mbox, omap_mbox_to_message(vqid));
         if (ret < 0)
                 dev_err(dev, "failed to send mailbox message, status = %d\n",
                         ret);
include/linux/omap-mailbox.h +3 -3
index 3cc5c4ed7f5a6..e45f8c3841c23 100644
@@ -6,8 +6,9 @@
  #ifndef OMAP_MAILBOX_H
  #define OMAP_MAILBOX_H
 
-typedef uintptr_t mbox_msg_t;
+typedef u32 mbox_msg_t;
 
-#define omap_mbox_message(data) (u32)(mbox_msg_t)(data)
+#define omap_mbox_to_message(data) ((void *)(uintptr_t)(data))
+#define omap_mbox_from_message(data) ((mbox_msg_t)(uintptr_t)(data))
 
  #endif /* OMAP_MAILBOX_H */
--

2.39.2

Reviewed-by Tested-by on v1 1/3
#8 lore raw
In reply to Andrew Davis
Quoted 6 lines · Andrew Davis

The header ti_k3_common.h uses several definitions in headers it does not include itself, this makes users of this header responsible for including the right headers first. Instead include what we need here. Then go and remove some headers that we do not use from the K3 Remoteproc drivers.

Thanks for cleaning this up. Test suite is happy.

Thanks,
Beleswar

Quoted 76 lines
---
  drivers/remoteproc/ti_k3_common.h         | 4 ++++
  drivers/remoteproc/ti_k3_dsp_remoteproc.c | 3 ---
  drivers/remoteproc/ti_k3_m4_remoteproc.c  | 4 +---
  drivers/remoteproc/ti_k3_r5_remoteproc.c  | 5 -----
  4 files changed, 5 insertions(+), 11 deletions(-)
drivers/remoteproc/ti_k3_common.h +4 -0
index aee3c28dbe510..c8430e42225fe 100644
@@ -21,6 +21,10 @@
  #ifndef REMOTEPROC_TI_K3_COMMON_H
  #define REMOTEPROC_TI_K3_COMMON_H
 
+#include <linux/mailbox_client.h>
+#include <linux/platform_device.h>
+#include <linux/types.h>
+
  #define KEYSTONE_RPROC_LOCAL_ADDRESS_MASK	(SZ_16M - 1)
 
  /**
drivers/remoteproc/ti_k3_dsp_remoteproc.c +0 -3
index d6ceea6dc920e..c916a86bc8294 100644
@@ -7,11 +7,8 @@
   */
 
  #include <linux/io.h>
-#include <linux/mailbox_client.h>
  #include <linux/module.h>
  #include <linux/of.h>
-#include <linux/of_reserved_mem.h>
-#include <linux/omap-mailbox.h>
  #include <linux/platform_device.h>
  #include <linux/remoteproc.h>
  #include <linux/reset.h>
drivers/remoteproc/ti_k3_m4_remoteproc.c +1 -3
index 3a11fd24eb52b..4c46f4a256a92 100644
@@ -7,10 +7,8 @@
   */
 
  #include <linux/io.h>
-#include <linux/mailbox_client.h>
  #include <linux/module.h>
-#include <linux/of_address.h>
-#include <linux/of_reserved_mem.h>
+#include <linux/of.h>
  #include <linux/platform_device.h>
  #include <linux/remoteproc.h>
  #include <linux/reset.h>
drivers/remoteproc/ti_k3_r5_remoteproc.c +0 -5
index b1d04d082e44c..404acc1a9bb7c 100644
@@ -6,17 +6,12 @@
   *	Suman Anna <[email protected]>
   */
 
-#include <linux/dma-mapping.h>
  #include <linux/err.h>
  #include <linux/interrupt.h>
-#include <linux/kernel.h>
-#include <linux/mailbox_client.h>
  #include <linux/module.h>
  #include <linux/of.h>
  #include <linux/of_address.h>
-#include <linux/of_reserved_mem.h>
  #include <linux/of_platform.h>
-#include <linux/omap-mailbox.h>
  #include <linux/platform_device.h>
  #include <linux/pm_runtime.h>
  #include <linux/remoteproc.h>
Reviewed-by Tested-by on v1 2/3
#4 lore raw

Re: [PATCH 2/3] remoteproc: k3-dsp: Fix usage of omap_mbox_message and mbox_msg_t

In reply to Andrew Davis
Quoted 11 lines · Andrew Davis

The type of message sent using omap-mailbox is always u32. The definition of mbox_msg_t is uintptr_t which is wrong as that type changes based on the architecture (32bit vs 64bit). Make the type fixed to u32.

This then means we need to fix the helper macro omap_mbox_message so it doesn't cast to u32 twice. What this macro should be doing is converting from the message type returned from the mailbox framework into the omap-mailbox type. When fixing this we should add a macro for the other direction (from omap-mailbox type to something that can be used with mbox_send_message).

Quoted 3 lines

After these changes, make use of the new macros as appropriate.

Thanks for cleaning this up. Test suite is happy.

Thanks,
Beleswar

Quoted 99 lines
---
  drivers/remoteproc/omap_remoteproc.c | 10 +++++-----
  drivers/remoteproc/ti_k3_common.c    | 10 ++--------
  include/linux/omap-mailbox.h         |  5 +++--
  3 files changed, 10 insertions(+), 15 deletions(-)
drivers/remoteproc/omap_remoteproc.c +5 -5
index 6ed0f28edac9c..efff95b8e363f 100644
@@ -499,7 +499,7 @@ static void omap_rproc_mbox_callback(struct mbox_client *client, void *data)
  						client);
  	struct device *dev = oproc->rproc->dev.parent;
  	const char *name = oproc->rproc->name;
-	u32 msg = (u32)data;
+	mbox_msg_t msg = omap_mbox_from_message(data);
 
  	dev_dbg(dev, "mbox msg: 0x%x\n", msg);
 
@@ -550,7 +550,7 @@ static void omap_rproc_kick(struct rproc *rproc, int vqid)
  	}
 
  	/* send the index of the triggered virtqueue in the mailbox payload */
-	ret = mbox_send_message(oproc->mbox, (void *)vqid);
+	ret = mbox_send_message(oproc->mbox, omap_mbox_to_message(vqid));
  	if (ret < 0)
  		dev_err(dev, "failed to send mailbox message, status = %d\n",
  			ret);
@@ -628,7 +628,7 @@ static int omap_rproc_start(struct rproc *rproc)
  	 * Note that the reply will _not_ arrive immediately: this message
  	 * will wait in the mailbox fifo until the remote processor is booted.
  	 */
-	ret = mbox_send_message(oproc->mbox, (void *)RP_MBOX_ECHO_REQUEST);
+	ret = mbox_send_message(oproc->mbox, omap_mbox_to_message(RP_MBOX_ECHO_REQUEST));
  	if (ret < 0) {
  		dev_err(dev, "mbox_send_message failed: %d\n", ret);
  		goto put_mbox;
@@ -777,13 +777,13 @@ static int _omap_rproc_suspend(struct rproc *rproc, bool auto_suspend)
  	struct omap_rproc *oproc = rproc->priv;
  	unsigned long to = msecs_to_jiffies(DEF_SUSPEND_TIMEOUT);
  	unsigned long ta = jiffies + to;
-	u32 suspend_msg = auto_suspend ?
+	mbox_msg_t suspend_msg = auto_suspend ?
  				RP_MBOX_SUSPEND_AUTO : RP_MBOX_SUSPEND_SYSTEM;
  	int ret;
 
  	reinit_completion(&oproc->pm_comp);
  	oproc->suspend_acked = false;
-	ret = mbox_send_message(oproc->mbox, (void *)suspend_msg);
+	ret = mbox_send_message(oproc->mbox, omap_mbox_to_message(suspend_msg));
  	if (ret < 0) {
  		dev_err(dev, "PM mbox_send_message failed: %d\n", ret);
  		return ret;
drivers/remoteproc/ti_k3_common.c +2 -8
index 3cb8ae5d72f67..4b6da3363f6c2 100644
@@ -54,7 +54,7 @@ void k3_rproc_mbox_callback(struct mbox_client *client, void *data)
  	struct k3_rproc *kproc = container_of(client, struct k3_rproc, client);
  	struct device *dev = kproc->rproc->dev.parent;
  	struct rproc *rproc = kproc->rproc;
-	u32 msg = (u32)(uintptr_t)(data);
+	mbox_msg_t msg = omap_mbox_from_message(data);
 
  	dev_dbg(dev, "mbox msg: 0x%x\n", msg);
 
@@ -94,15 +94,9 @@ void k3_rproc_kick(struct rproc *rproc, int vqid)
  {
  	struct k3_rproc *kproc = rproc->priv;
  	struct device *dev = kproc->dev;
-	u32 msg = (u32)vqid;
  	int ret;
 
-	/*
-	 * Send the index of the triggered virtqueue in the mailbox payload.
-	 * NOTE: msg is cast to uintptr_t to prevent compiler warnings when
-	 * void* is 64bit. It is safely cast back to u32 in the mailbox driver.
-	 */
-	ret = mbox_send_message(kproc->mbox, (void *)(uintptr_t)msg);
+	ret = mbox_send_message(kproc->mbox, omap_mbox_to_message(vqid));
  	if (ret < 0)
  		dev_err(dev, "failed to send mailbox message, status = %d\n",
  			ret);
include/linux/omap-mailbox.h +3 -2
index 3cc5c4ed7f5a6..e45f8c3841c23 100644
@@ -6,8 +6,9 @@
  #ifndef OMAP_MAILBOX_H
  #define OMAP_MAILBOX_H
 
-typedef uintptr_t mbox_msg_t;
+typedef u32 mbox_msg_t;
 
-#define omap_mbox_message(data) (u32)(mbox_msg_t)(data)
+#define omap_mbox_to_message(data) ((void *)(uintptr_t)(data))
+#define omap_mbox_from_message(data) ((mbox_msg_t)(uintptr_t)(data))
 
  #endif /* OMAP_MAILBOX_H */
Reviewed-by Tested-by on v1 3/3
#6 lore raw

Re: [PATCH 3/3] remoteproc: Add compile testing for additional TI drivers

In reply to Andrew Davis
Quoted 6 lines · Andrew Davis

Many Remoteproc drivers, including K3, can and are built for compile testing. The WKUP_M3, Keystone, and DA8xx can be also, enable this here.

Doing this exposes a compile warning on 64bit platforms as size_t changes size, use the correct printf format specifier for size_t.

Quoted 6 lines

We cannot compile test for OMAP_REMOTEPROC due to dependency on OMAP clock framework. But while here fix up the Kconfig help text which claims this driver only works for OMAP4, when it really works across several OMAP-class devices.

Thanks for cleaning this up. Test suite is happy.

Nit: A cover letter would be good to send R/B and T/B for the entire series.

Thanks,
Beleswar

Quoted 60 lines
---
  drivers/remoteproc/Kconfig           | 10 ++++------
  drivers/remoteproc/omap_remoteproc.c |  2 +-
  2 files changed, 5 insertions(+), 7 deletions(-)
drivers/remoteproc/Kconfig +4 -6
index 5b56b2dcc725f..73500fdc227db 100644
@@ -83,9 +83,7 @@ config OMAP_REMOTEPROC
  	select OMAP2PLUS_MBOX
  	help
  	  Say y here to support OMAP's remote processors (dual M3
-	  and DSP on OMAP4) via the remote processor framework.
-
-	  Currently only supported on OMAP4.
+	  and DSP) via the remote processor framework.
 
  	  Usually you want to say Y here, in order to enable multimedia
  	  use-cases to run on your platform (multimedia codecs are
@@ -108,7 +106,7 @@ config OMAP_REMOTEPROC_WATCHDOG
 
  config WKUP_M3_RPROC
  	tristate "AMx3xx Wakeup M3 remoteproc support"
-	depends on SOC_AM33XX || SOC_AM43XX
+	depends on SOC_AM33XX || SOC_AM43XX || COMPILE_TEST
  	help
  	  Say y here to support Wakeup M3 remote processor on TI AM33xx
  	  and AM43xx family of SoCs.
@@ -120,7 +118,7 @@ config WKUP_M3_RPROC
 
  config DA8XX_REMOTEPROC
  	tristate "DA8xx/OMAP-L13x remoteproc support"
-	depends on ARCH_DAVINCI_DA8XX
+	depends on ARCH_DAVINCI_DA8XX || COMPILE_TEST
  	depends on DMA_CMA
  	help
  	  Say y here to support DA8xx/OMAP-L13x remote processors via the
@@ -141,7 +139,7 @@ config DA8XX_REMOTEPROC
 
  config KEYSTONE_REMOTEPROC
  	tristate "Keystone Remoteproc support"
-	depends on ARCH_KEYSTONE
+	depends on ARCH_KEYSTONE || COMPILE_TEST
  	help
  	  Say Y here here to support Keystone remote processors (DSP)
  	  via the remote processor framework.
drivers/remoteproc/omap_remoteproc.c +1 -1
index efff95b8e363f..1e96506ce7ca7 100644
@@ -1208,7 +1208,7 @@ static int omap_rproc_of_get_internal_memories(struct platform_device *pdev,
  		oproc->mem[i].dev_addr = data->mems[i].dev_addr;
  		oproc->mem[i].size = resource_size(res);
 
-		dev_dbg(dev, "memory %8s: bus addr %pa size 0x%x va %p da 0x%x\n",
+		dev_dbg(dev, "memory %8s: bus addr %pa size 0x%zx va %p da 0x%x\n",
  			data->mems[i].name, &oproc->mem[i].bus_addr,
  			oproc->mem[i].size, oproc->mem[i].cpu_addr,
  			oproc->mem[i].dev_addr);
maintainer
#7 lore raw

Re: [PATCH 3/3] remoteproc: Add compile testing for additional TI drivers

Quoted 16 lines · Beleswar
Quoted 6 lines · Andrew Davis

Many Remoteproc drivers, including K3, can and are built for compile testing. The WKUP_M3, Keystone, and DA8xx can be also, enable this here.

Doing this exposes a compile warning on 64bit platforms as size_t changes size, use the correct printf format specifier for size_t.

Quoted 6 lines

We cannot compile test for OMAP_REMOTEPROC due to dependency on OMAP clock framework. But while here fix up the Kconfig help text which claims this driver only works for OMAP4, when it really works across several OMAP-class devices.

Quoted 6 lines

Thanks for cleaning this up. Test suite is happy.

Nit: A cover letter would be good to send R/B and T/B for the entire series.

I agree with Beleswar. I applied all 3 patches.

Thanks,
Mathieu

Quoted 59 lines

Thanks,
Beleswar

Quoted 55 lines
---
  drivers/remoteproc/Kconfig           | 10 ++++------
  drivers/remoteproc/omap_remoteproc.c |  2 +-
  2 files changed, 5 insertions(+), 7 deletions(-)
drivers/remoteproc/Kconfig +4 -6
index 5b56b2dcc725f..73500fdc227db 100644
@@ -83,9 +83,7 @@ config OMAP_REMOTEPROC
  	select OMAP2PLUS_MBOX
  	help
  	  Say y here to support OMAP's remote processors (dual M3
-	  and DSP on OMAP4) via the remote processor framework.
-
-	  Currently only supported on OMAP4.
+	  and DSP) via the remote processor framework.
  	  Usually you want to say Y here, in order to enable multimedia
  	  use-cases to run on your platform (multimedia codecs are
@@ -108,7 +106,7 @@ config OMAP_REMOTEPROC_WATCHDOG
  config WKUP_M3_RPROC
  	tristate "AMx3xx Wakeup M3 remoteproc support"
-	depends on SOC_AM33XX || SOC_AM43XX
+	depends on SOC_AM33XX || SOC_AM43XX || COMPILE_TEST
  	help
  	  Say y here to support Wakeup M3 remote processor on TI AM33xx
  	  and AM43xx family of SoCs.
@@ -120,7 +118,7 @@ config WKUP_M3_RPROC
  config DA8XX_REMOTEPROC
  	tristate "DA8xx/OMAP-L13x remoteproc support"
-	depends on ARCH_DAVINCI_DA8XX
+	depends on ARCH_DAVINCI_DA8XX || COMPILE_TEST
  	depends on DMA_CMA
  	help
  	  Say y here to support DA8xx/OMAP-L13x remote processors via the
@@ -141,7 +139,7 @@ config DA8XX_REMOTEPROC
  config KEYSTONE_REMOTEPROC
  	tristate "Keystone Remoteproc support"
-	depends on ARCH_KEYSTONE
+	depends on ARCH_KEYSTONE || COMPILE_TEST
  	help
  	  Say Y here here to support Keystone remote processors (DSP)
  	  via the remote processor framework.
drivers/remoteproc/omap_remoteproc.c +1 -1
index efff95b8e363f..1e96506ce7ca7 100644
@@ -1208,7 +1208,7 @@ static int omap_rproc_of_get_internal_memories(struct platform_device *pdev,
  		oproc->mem[i].dev_addr = data->mems[i].dev_addr;
  		oproc->mem[i].size = resource_size(res);
-		dev_dbg(dev, "memory %8s: bus addr %pa size 0x%x va %p da 0x%x\n",
+		dev_dbg(dev, "memory %8s: bus addr %pa size 0x%zx va %p da 0x%x\n",
  			data->mems[i].name, &oproc->mem[i].bus_addr,
  			oproc->mem[i].size, oproc->mem[i].cpu_addr,
  			oproc->mem[i].dev_addr);