linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Diana Craciun <diana.craciun@nxp.com>
To: linux-kernel@vger.kernel.org, laurentiu.tudor@nxp.com,
	gregkh@linuxfoundation.org
Cc: stuyoder@gmail.com, leoyang.li@nxp.com,
	linux-arm-kernel@lists.infradead.org, bharatb.linux@gmail.com,
	Diana Craciun <diana.craciun@oss.nxp.com>
Subject: [PATCH v3 13/13] bus/fsl-mc: Add a new version for dprc_get_obj_region command
Date: Mon,  6 Jul 2020 15:42:43 +0300	[thread overview]
Message-ID: <20200706124243.10697-14-diana.craciun@nxp.com> (raw)
In-Reply-To: <20200706124243.10697-1-diana.craciun@nxp.com>

From: Diana Craciun <diana.craciun@oss.nxp.com>

The region size reported by the firmware for mc and software
portals was less than allocated by the hardware. This may be
problematic when mmapping the region in user space because the
region size is less than page size. However the size as reserved
by the hardware is 64K.

Signed-off-by: Diana Craciun <diana.craciun@oss.nxp.com>
---
 drivers/bus/fsl-mc/dprc.c           | 38 ++++++++++++++++++-----------
 drivers/bus/fsl-mc/fsl-mc-private.h |  3 +++
 2 files changed, 27 insertions(+), 14 deletions(-)

diff --git a/drivers/bus/fsl-mc/dprc.c b/drivers/bus/fsl-mc/dprc.c
index 3f08752c2c19..ba292c56fe19 100644
--- a/drivers/bus/fsl-mc/dprc.c
+++ b/drivers/bus/fsl-mc/dprc.c
@@ -536,20 +536,30 @@ int dprc_get_obj_region(struct fsl_mc_io *mc_io,
 			return err;
 	}
 
-	/**
-	 * MC API version 6.3 introduced a new field to the region
-	 * descriptor: base_address. If the older API is in use then the base
-	 * address is set to zero to indicate it needs to be obtained elsewhere
-	 * (typically the device tree).
-	 */
-	if (dprc_major_ver > 6 || (dprc_major_ver == 6 && dprc_minor_ver >= 3))
-		cmd.header =
-			mc_encode_cmd_header(DPRC_CMDID_GET_OBJ_REG_V2,
-					     cmd_flags, token);
-	else
-		cmd.header =
-			mc_encode_cmd_header(DPRC_CMDID_GET_OBJ_REG,
-					     cmd_flags, token);
+	if (dprc_major_ver > 6 || (dprc_major_ver == 6 && dprc_minor_ver >= 6)) {
+		/**
+		 * MC API version 6.6 changed the size of the MC portals and software
+		 * portals to 64K (as implemented by hardware). If older API is in use the
+		 * size reported is less (64 bytes for mc portals and 4K for software
+		 * portals).
+		 */
+
+		cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_OBJ_REG_V3,
+						  cmd_flags, token);
+
+	} else if (dprc_major_ver == 6 && dprc_minor_ver >= 3) {
+		/**
+		 * MC API version 6.3 introduced a new field to the region
+		 * descriptor: base_address. If the older API is in use then the base
+		 * address is set to zero to indicate it needs to be obtained elsewhere
+		 * (typically the device tree).
+		 */
+		cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_OBJ_REG_V2,
+						  cmd_flags, token);
+	} else {
+		cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_OBJ_REG,
+						  cmd_flags, token);
+	}
 
 	cmd_params = (struct dprc_cmd_get_obj_region *)cmd.params;
 	cmd_params->obj_id = cpu_to_le32(obj_id);
diff --git a/drivers/bus/fsl-mc/fsl-mc-private.h b/drivers/bus/fsl-mc/fsl-mc-private.h
index e6fcff12c68d..8d65273a78d7 100644
--- a/drivers/bus/fsl-mc/fsl-mc-private.h
+++ b/drivers/bus/fsl-mc/fsl-mc-private.h
@@ -80,10 +80,12 @@ int dpmcp_reset(struct fsl_mc_io *mc_io,
 /* DPRC command versioning */
 #define DPRC_CMD_BASE_VERSION			1
 #define DPRC_CMD_2ND_VERSION			2
+#define DPRC_CMD_3RD_VERSION			3
 #define DPRC_CMD_ID_OFFSET			4
 
 #define DPRC_CMD(id)	(((id) << DPRC_CMD_ID_OFFSET) | DPRC_CMD_BASE_VERSION)
 #define DPRC_CMD_V2(id)	(((id) << DPRC_CMD_ID_OFFSET) | DPRC_CMD_2ND_VERSION)
+#define DPRC_CMD_V3(id)	(((id) << DPRC_CMD_ID_OFFSET) | DPRC_CMD_3RD_VERSION)
 
 /* DPRC command IDs */
 #define DPRC_CMDID_CLOSE                        DPRC_CMD(0x800)
@@ -105,6 +107,7 @@ int dpmcp_reset(struct fsl_mc_io *mc_io,
 #define DPRC_CMDID_GET_OBJ                      DPRC_CMD(0x15A)
 #define DPRC_CMDID_GET_OBJ_REG                  DPRC_CMD(0x15E)
 #define DPRC_CMDID_GET_OBJ_REG_V2               DPRC_CMD_V2(0x15E)
+#define DPRC_CMDID_GET_OBJ_REG_V3               DPRC_CMD_V3(0x15E)
 #define DPRC_CMDID_SET_OBJ_IRQ                  DPRC_CMD(0x15F)
 
 #define DPRC_CMDID_GET_CONNECTION               DPRC_CMD(0x16C)
-- 
2.17.1


  parent reply	other threads:[~2020-07-06 12:43 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-06 12:42 [PATCH v3 00/13] bus/fsl-mc: Extend mc-bus driver functionalities in preparation for mc-bus VFIO support Diana Craciun
2020-07-06 12:42 ` [PATCH v3 01/13] bus/fsl-mc: Do no longer export the total number of irqs outside dprc_scan_objects Diana Craciun
2020-07-06 12:42 ` [PATCH v3 02/13] bus/fsl-mc: Add a new parameter to dprc_scan_objects function Diana Craciun
2020-07-06 12:42 ` [PATCH v3 03/13] bus/fsl-mc: add support for 'driver_override' in the mc-bus Diana Craciun
2020-07-06 13:57   ` Andrew Lunn
2020-07-06 16:35     ` Diana Craciun OSS
2020-07-06 12:42 ` [PATCH v3 04/13] bus/fsl-mc: Set the QMAN/BMAN region flags Diana Craciun
2020-07-06 12:42 ` [PATCH v3 05/13] bus/fsl-mc: Cache the DPRC API version Diana Craciun
2020-07-06 12:42 ` [PATCH v3 06/13] bus/fsl-mc: Add dprc-reset-container support Diana Craciun
2020-07-06 12:42 ` [PATCH v3 07/13] bus/fsl-mc: Export a dprc scan function to be used by multiple entities Diana Craciun
2020-07-06 12:42 ` [PATCH v3 08/13] bus/fsl-mc: Export a cleanup function for DPRC Diana Craciun
2020-07-06 12:42 ` [PATCH v3 09/13] bus/fsl-mc: Add a container setup function Diana Craciun
2020-07-06 12:42 ` [PATCH v3 10/13] bus/fsl_mc: Do not rely on caller to provide non NULL mc_io Diana Craciun
2020-07-06 12:42 ` [PATCH v3 11/13] bus/fsl-mc: Export IRQ pool handling functions to be used by VFIO Diana Craciun
2020-07-06 12:42 ` [PATCH v3 12/13] bus/fsl-mc: Extend ICID size from 16bit to 32bit Diana Craciun
2020-07-06 12:42 ` Diana Craciun [this message]
2020-07-06 13:14   ` [PATCH v3 13/13] bus/fsl-mc: Add a new version for dprc_get_obj_region command Laurentiu Tudor
2020-07-06 15:49     ` Diana Craciun OSS

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=20200706124243.10697-14-diana.craciun@nxp.com \
    --to=diana.craciun@nxp.com \
    --cc=bharatb.linux@gmail.com \
    --cc=diana.craciun@oss.nxp.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=laurentiu.tudor@nxp.com \
    --cc=leoyang.li@nxp.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stuyoder@gmail.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;
as well as URLs for NNTP newsgroup(s).