mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Loic Pallardy <loic.pallardy@st.com>
To: <bjorn.andersson@linaro.org>, <ohad@wizery.com>
Cc: <linux-remoteproc@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <arnaud.pouliquen@st.com>,
	<benjamin.gaignard@linaro.org>, <s-anna@ti.com>,
	Loic Pallardy <loic.pallardy@st.com>
Subject: [PATCH v2 4/7] remoteproc: add warning on resource table cast
Date: Thu, 10 Jan 2019 14:49:08 +0100	[thread overview]
Message-ID: <1547128151-44077-5-git-send-email-loic.pallardy@st.com> (raw)
In-Reply-To: <1547128151-44077-1-git-send-email-loic.pallardy@st.com>

Today resource table supports only 32bit address fields.
This is not compliant with 64bit platform for which addresses
are cast in 32bit.
This patch adds warn messages when address cast is done.

Signed-off-by: Loic Pallardy <loic.pallardy@st.com>

---
Changes from v1:
- modify implementation to display warning message only when
  data are modified by cast operation
---
 drivers/remoteproc/remoteproc_core.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index 18a1bbf820c9..0ecd37993f41 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -45,6 +45,8 @@
 
 #include "remoteproc_internal.h"
 
+#define HIGH_BITS_MASK 0xFFFFFFFF00000000ULL
+
 static DEFINE_MUTEX(rproc_list_mutex);
 static LIST_HEAD(rproc_list);
 
@@ -772,6 +774,10 @@ static int rproc_alloc_carveout(struct rproc *rproc,
 		dev_dbg(dev, "carveout mapped 0x%x to %pad\n",
 			mem->da, &dma);
 	} else {
+		/* Update device address as undefined by requester */
+		if ((u64)dma & HIGH_BITS_MASK)
+			dev_warn(dev, "DMA address cast in 32bit to fit resource table format\n");
+
 		mem->da = (u32)dma;
 	}
 
@@ -1115,6 +1121,7 @@ static int rproc_alloc_registered_carveouts(struct rproc *rproc)
 	struct rproc_mem_entry *entry, *tmp;
 	struct fw_rsc_carveout *rsc;
 	struct device *dev = &rproc->dev;
+	u64 pa;
 	int ret;
 
 	list_for_each_entry_safe(entry, tmp, &rproc->carveouts, node) {
@@ -1151,10 +1158,15 @@ static int rproc_alloc_registered_carveouts(struct rproc *rproc)
 
 			/* Use va if defined else dma to generate pa */
 			if (entry->va)
-				rsc->pa = (u32)rproc_va_to_pa(entry->va);
+				pa = (u64)rproc_va_to_pa(entry->va);
 			else
-				rsc->pa = (u32)entry->dma;
+				pa = (u64)entry->dma;
+
+			if (((u64)pa) & HIGH_BITS_MASK)
+				dev_warn(dev,
+					 "Physical address cast in 32bit to fit resource table format\n");
 
+			rsc->pa = (u32)pa;
 			rsc->da = entry->da;
 			rsc->len = entry->len;
 		}
-- 
2.7.4


  parent reply	other threads:[~2019-01-10 13:49 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-10 13:49 [PATCH v2 0/7] remoteproc: Fixes for memoy carveout management Loic Pallardy
2019-01-10 13:49 ` [PATCH v2 1/7] remoteproc: correct rproc_mem_entry_init() comments Loic Pallardy
2019-01-10 13:49 ` [PATCH v2 2/7] remoteproc: fix rproc_da_to_va in case of unallocated carveout Loic Pallardy
2019-01-10 13:49 ` [PATCH v2 3/7] remoteproc: fix rproc_alloc_carveout() bad variable cast Loic Pallardy
2019-01-10 13:49 ` Loic Pallardy [this message]
2019-01-10 13:49 ` [PATCH v2 5/7] remoteproc: fix rproc_alloc_carveout() for rproc with iommu domain Loic Pallardy
2019-01-10 13:49 ` [PATCH v2 6/7] remoteproc: fix trace buffer va initialization Loic Pallardy
2019-01-10 13:49 ` [PATCH v2 7/7] remoteproc: fix rproc_check_carveout_da() returned error and comments Loic Pallardy
2019-02-01 15:59 ` [PATCH v2 0/7] remoteproc: Fixes for memoy carveout management Loic PALLARDY

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1547128151-44077-5-git-send-email-loic.pallardy@st.com \
    --to=loic.pallardy@st.com \
    --cc=arnaud.pouliquen@st.com \
    --cc=benjamin.gaignard@linaro.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-remoteproc@vger.kernel.org \
    --cc=ohad@wizery.com \
    --cc=s-anna@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®