soc: fsl: dpio: Add support for memory backed QBMan portals
cover soc: fsl: dpio: Add support for memory backed QBMan portals
This patch series adds support for QBMan memory backed portals which is avaialble in devices containing QBMan verion 5.0 and above (for example NXP's LX2160A SoC).
Memory backed portals can be mapped as normal cacheable/shareable memory which allows the portals to migrate between cores without needing manual cache manipulations by the CPU.
The patches add support for the new portal attributes in the fsl-mc bus drivers as well as modifying the QBMan driver to use the new portal read trigger mechanism.
Roy Pledge (2):
bus: mc-bus: Add support for mapping shareable portals
soc: fsl: dpio: Add support for memory backed QBMan portals
drivers/bus/fsl-mc/dprc.c | 3 +- drivers/bus/fsl-mc/fsl-mc-bus.c | 14 +++- drivers/bus/fsl-mc/fsl-mc-private.h | 17 ++++- drivers/soc/fsl/dpio/dpio-driver.c | 23 ++++-- drivers/soc/fsl/dpio/qbman-portal.c | 148 ++++++++++++++++++++++++++++++------ drivers/soc/fsl/dpio/qbman-portal.h | 5 ++ 6 files changed, 172 insertions(+), 38 deletions(-)
--
2.7.4
PATCH 1/2 bus: mc-bus: Add support for mapping shareable portals
Starting with v5 of NXP QBMan devices the hardware supports using regular cacheable/shareable memory as the backing store for the portals.
This patch adds support for the new portal mode by switching to use the DPRC get object region v2 command which returns both a base address and offset for the portal memory. The new portal region is identified as shareable through the addition of a new flag.
--- drivers/bus/fsl-mc/dprc.c | 3 ++- drivers/bus/fsl-mc/fsl-mc-bus.c | 14 ++++++++++++-- drivers/bus/fsl-mc/fsl-mc-private.h | 17 ++++++++++++++--- 3 files changed, 28 insertions(+), 6 deletions(-)
drivers/bus/fsl-mc/dprc.c +2 -1
@@ -461,8 +461,9 @@ int dprc_get_obj_region(struct fsl_mc_io *mc_io,/* retrieve response parameters */ rsp_params = (struct dprc_rsp_get_obj_region *)cmd.params; - region_desc->base_offset =le64_to_cpu (rsp_params->base_addr); + region_desc->base_offset =le64_to_cpu (rsp_params->base_offset); region_desc->size =le32_to_cpu (rsp_params->size); + region_desc->base_address =le64_to_cpu (rsp_params->base_addr);return 0 ; }
drivers/bus/fsl-mc/fsl-mc-bus.c +12 -2
@@ -487,10 +487,18 @@ static int fsl_mc_device_get_mmio_regions(struct fsl_mc_device *mc_dev, "dprc_get_obj_region() failed: %d\n", error); goto error_cleanup_regions; } - - error =translate_mc_addr (mc_dev, mc_region_type, +/* Older MC only returned region offset and no base address +* If base address is in the region_desc use it otherwise +* revert to old mechanism +*/ +if (region_desc.base_address) + regions[i].start = region_desc.base_address + + region_desc.base_offset; +else + error =translate_mc_addr (mc_dev, mc_region_type, region_desc.base_offset, ®ions[i].start); +if (error <0 ) { dev_err(parent_dev, "Invalid MC offset: %#x (for %s.%d\'s region %d)\n",
@@ -504,6 +512,8 @@ static int fsl_mc_device_get_mmio_regions(struct fsl_mc_device *mc_dev, regions[i].flags =IORESOURCE_IO ;if (region_desc.flags &DPRC_REGION_CACHEABLE ) regions[i].flags |=IORESOURCE_CACHEABLE ; +if (region_desc.flags &DPRC_REGION_SHAREABLE ) + regions[i].flags |=IORESOURCE_MEM ; } mc_dev->regions = regions;
drivers/bus/fsl-mc/fsl-mc-private.h +14 -3
@@ -79,9 +79,11 @@ 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_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)/* DPRC command IDs */ #define DPRC_CMDID_CLOSE DPRC_CMD(0x800)
@@ -99,7 +101,7 @@ int dpmcp_reset(struct fsl_mc_io *mc_io,#define DPRC_CMDID_GET_CONT_ID DPRC_CMD(0x830)#define DPRC_CMDID_GET_OBJ_COUNT DPRC_CMD(0x159)#define DPRC_CMDID_GET_OBJ DPRC_CMD(0x15A) -#define DPRC_CMDID_GET_OBJ_REG DPRC_CMD(0x15E) +#define DPRC_CMDID_GET_OBJ_REG DPRC_CMD_V2(0x15E)#define DPRC_CMDID_SET_OBJ_IRQ DPRC_CMD(0x15F)struct dprc_cmd_open {
@@ -199,9 +201,15 @@ struct dprc_rsp_get_obj_region {/* response word 0 */ __le64 pad;/* response word 1 */ -__le64 base_addr; +__le64 base_offset;/* response word 2 */ __le32 size; +u8 pad2[3 ]; +/* response word 3 */ +__le32 flags; +__le32 pad3; +/* response word 4 */ +__le64 base_addr; };struct dprc_cmd_set_obj_irq {
@@ -334,6 +342,7 @@ int dprc_set_obj_irq(struct fsl_mc_io *mc_io,/* Region flags */ /* Cacheable - Indicates that region should be mapped as cacheable */ #define DPRC_REGION_CACHEABLE 0x00000001 +#define DPRC_REGION_SHAREABLE 0x00000002/** * enum dprc_region_type - Region type
@@ -342,7 +351,8 @@ int dprc_set_obj_irq(struct fsl_mc_io *mc_io,*/ enum dprc_region_type {DPRC_REGION_TYPE_MC_PORTAL , -DPRC_REGION_TYPE_QBMAN_PORTAL +DPRC_REGION_TYPE_QBMAN_PORTAL , +DPRC_REGION_TYPE_QBMAN_MEM_BACKED_PORTAL };/**
@@ -360,6 +370,7 @@ struct dprc_region_desc {u32 size;u32 flags;enum dprc_region_type type; +u64 base_address; }; int dprc_get_obj_region(struct fsl_mc_io *mc_io,
Signature · 1 line
2.7.4
PATCH 2/2 soc: fsl: dpio: Add support for memory backed QBMan portals
In reply to Roy PledgeNXP devices with QBMan version 5 and above can enable software portals that are memory backed. This allows the portal to be mapped as cacheable/sharable (same as all normal memory) so that portals can freely migrate between cores and clusters in the SoC. The driver will enable this mode by default when appropriate HW support is detected.
--- drivers/soc/fsl/dpio/dpio-driver.c | 23 ++++-- drivers/soc/fsl/dpio/qbman-portal.c | 148 ++++++++++++++++++++++++++++++------ drivers/soc/fsl/dpio/qbman-portal.h | 5 ++ 3 files changed, 144 insertions(+), 32 deletions(-)
drivers/soc/fsl/dpio/dpio-driver.c +16 -7
@@ -140,13 +140,22 @@ static int dpaa2_dpio_probe(struct fsl_mc_device *dpio_dev) } desc.cpu = next_cpu; -/* -* Set the CENA regs to be the cache inhibited area of the portal to -* avoid coherency issues if a user migrates to another core. -*/ - desc.regs_cena =devm_memremap (dev, dpio_dev->regions[1 ].start, -resource_size (&dpio_dev->regions[1 ]), -MEMREMAP_WC ); +if (dpio_dev->obj_desc.region_count <3 ) { +/* No support for DDR backed portals, use classic mapping */ +/* +* Set the CENA regs to be the cache inhibited area of the +* portal to avoid coherency issues if a user migrates to +* another core. +*/ + desc.regs_cena =devm_memremap (dev, dpio_dev->regions[1 ].start, +resource_size (&dpio_dev->regions[1 ]), +MEMREMAP_WC ); + }else { + desc.regs_cena =devm_memremap (dev, dpio_dev->regions[2 ].start, +resource_size (&dpio_dev->regions[2 ]), +MEMREMAP_WB ); + } +if (IS_ERR (desc.regs_cena)) {dev_err (dev,"devm_memremap failed\n" ); err =PTR_ERR (desc.regs_cena);
drivers/soc/fsl/dpio/qbman-portal.c +123 -25
270 lines not on this page · raw message
drivers/soc/fsl/dpio/qbman-portal.h +5 -0
@@ -110,6 +110,11 @@ struct qbman_swp {u32 valid_bit;/* 0x00 or 0x80 */ } mc; +/* Management response */ +struct { +u32 valid_bit;/* 0x00 or 0x80 */ + } mr; +/* Push dequeues */ u32 sdq;
Signature · 1 line
2.7.4
Re: [PATCH v1 1/2] bus: mc-bus: Add support for mapping shareable portals
In reply to Roy PledgeQuoted 37 lines · Roy Pledge
Starting with v5 of NXP QBMan devices the hardware supports using regular cacheable/shareable memory as the backing store for the portals.
This patch adds support for the new portal mode by switching to use the DPRC get object region v2 command which returns both a base address and offset for the portal memory. The new portal region is identified as shareable through the addition of a new flag.
Signed-off-by Roy Pledge <[email protected]>--- drivers/bus/fsl-mc/dprc.c | 3 ++- drivers/bus/fsl-mc/fsl-mc-bus.c | 14 ++++++++++++-- drivers/bus/fsl-mc/fsl-mc-private.h | 17 ++++++++++++++--- 3 files changed, 28 insertions(+), 6 deletions(-)drivers/bus/fsl-mc/dprc.c +2
-1@@ -461,8 +461,9 @@ int dprc_get_obj_region(struct fsl_mc_io *mc_io,/* retrieve response parameters */ rsp_params = (struct dprc_rsp_get_obj_region *)cmd.params; - region_desc->base_offset =le64_to_cpu (rsp_params->base_addr); + region_desc->base_offset =le64_to_cpu (rsp_params->base_offset); region_desc->size =le32_to_cpu (rsp_params->size); + region_desc->base_address =le64_to_cpu (rsp_params->base_addr);return 0 ; }drivers/bus/fsl-mc/fsl-mc-bus.c +0
-0
drivers/bus/fsl-mc/fsl-mc-bus.c static int fsl_mc_device_get_mmio_regions(struct fsl_mc_device *mc_dev, · line 490
Quoted 6 lines
drivers/bus/fsl-mc/fsl-mc-bus.c +1
-2@@ -487,10 +487,18 @@ static int fsl_mc_device_get_mmio_regions(struct fsl_mc_device *mc_dev, "dprc_get_obj_region() failed: %d\n", error); goto error_cleanup_regions; } - - error = translate_mc_addr(mc_dev, mc_region_type, +/* Older MC only returned region offset and no base address
Nitpick: comment style is not consistent with existing code in fsl-mc.
Quoted 49 lines
drivers/bus/fsl-mc/fsl-mc-bus.c +11
-0+* If base address is in the region_desc use it otherwise +* revert to old mechanism +*/ +if (region_desc.base_address) + regions[i].start = region_desc.base_address + + region_desc.base_offset; +else + error =translate_mc_addr (mc_dev, mc_region_type, region_desc.base_offset, ®ions[i].start); +if (error <0 ) { dev_err(parent_dev, "Invalid MC offset: %#x (for %s.%d\'s region %d)\n",@@ -504,6 +512,8 @@ static int fsl_mc_device_get_mmio_regions(struct fsl_mc_device *mc_dev, regions[i].flags =IORESOURCE_IO ;if (region_desc.flags &DPRC_REGION_CACHEABLE ) regions[i].flags |=IORESOURCE_CACHEABLE ; +if (region_desc.flags &DPRC_REGION_SHAREABLE ) + regions[i].flags |=IORESOURCE_MEM ; } mc_dev->regions = regions;drivers/bus/fsl-mc/fsl-mc-private.h +3
-1@@ -79,9 +79,11 @@ 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_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)/* DPRC command IDs */ #define DPRC_CMDID_CLOSE DPRC_CMD(0x800)@@ -99,7 +101,7 @@ int dpmcp_reset(struct fsl_mc_io *mc_io,#define DPRC_CMDID_GET_CONT_ID DPRC_CMD(0x830)#define DPRC_CMDID_GET_OBJ_COUNT DPRC_CMD(0x159)#define DPRC_CMDID_GET_OBJ DPRC_CMD(0x15A) -#define DPRC_CMDID_GET_OBJ_REG DPRC_CMD(0x15E) +#define DPRC_CMDID_GET_OBJ_REG DPRC_CMD_V2(0x15E)#define DPRC_CMDID_SET_OBJ_IRQ DPRC_CMD(0x15F)struct dprc_cmd_open {
drivers/bus/fsl-mc/fsl-mc-private.h struct dprc_rsp_get_obj_region { · line 207
Quoted 8 lines
drivers/bus/fsl-mc/fsl-mc-private.h +2
-1@@ -199,9 +201,15 @@ struct dprc_rsp_get_obj_region {/* response word 0 */ __le64 pad;/* response word 1 */ -__le64 base_addr; +__le64 base_offset;/* response word 2 */ __le32 size; +u8 pad2[3 ];
Padding size (3B) is incorrect.
Either add 4B of padding:__le32 pad2;
or expose the "type" field:
u8 type;
u8 pad2[3];
Quoted 9 lines
drivers/bus/fsl-mc/fsl-mc-private.h +5
-0+/* response word 3 */ +__le32 flags; +__le32 pad3; +/* response word 4 */ +__le64 base_addr; };struct dprc_cmd_set_obj_irq {
drivers/bus/fsl-mc/fsl-mc-private.h int dprc_set_obj_irq(struct fsl_mc_io *mc_io, · line 346
Quoted 5 lines
drivers/bus/fsl-mc/fsl-mc-private.h +1
-0@@ -334,6 +342,7 @@ int dprc_set_obj_irq(struct fsl_mc_io *mc_io,/* Region flags */ /* Cacheable - Indicates that region should be mapped as cacheable */ #define DPRC_REGION_CACHEABLE 0x00000001 +#define DPRC_REGION_SHAREABLE 0x00000002
The new flag should be added in documentation (DPAA2 UM).
Regards,
Horia
Re: [PATCH v1 1/2] bus: mc-bus: Add support for mapping shareable portals
In reply to Roy PledgeHi Roy,
Quoted 83 lines · Roy Pledge
Starting with v5 of NXP QBMan devices the hardware supports using regular cacheable/shareable memory as the backing store for the portals.
This patch adds support for the new portal mode by switching to use the DPRC get object region v2 command which returns both a base address and offset for the portal memory. The new portal region is identified as shareable through the addition of a new flag.
Signed-off-by Roy Pledge <[email protected]>--- drivers/bus/fsl-mc/dprc.c | 3 ++- drivers/bus/fsl-mc/fsl-mc-bus.c | 14 ++++++++++++-- drivers/bus/fsl-mc/fsl-mc-private.h | 17 ++++++++++++++--- 3 files changed, 28 insertions(+), 6 deletions(-)drivers/bus/fsl-mc/dprc.c +2
-1@@ -461,8 +461,9 @@ int dprc_get_obj_region(struct fsl_mc_io *mc_io,/* retrieve response parameters */ rsp_params = (struct dprc_rsp_get_obj_region *)cmd.params; - region_desc->base_offset =le64_to_cpu (rsp_params->base_addr); + region_desc->base_offset =le64_to_cpu (rsp_params->base_offset); region_desc->size =le32_to_cpu (rsp_params->size); + region_desc->base_address =le64_to_cpu (rsp_params->base_addr);return 0 ; }drivers/bus/fsl-mc/fsl-mc-bus.c +12
-2@@ -487,10 +487,18 @@ static int fsl_mc_device_get_mmio_regions(struct fsl_mc_device *mc_dev, "dprc_get_obj_region() failed: %d\n", error); goto error_cleanup_regions; } - - error =translate_mc_addr (mc_dev, mc_region_type, +/* Older MC only returned region offset and no base address +* If base address is in the region_desc use it otherwise +* revert to old mechanism +*/ +if (region_desc.base_address) + regions[i].start = region_desc.base_address + + region_desc.base_offset; +else + error =translate_mc_addr (mc_dev, mc_region_type, region_desc.base_offset, ®ions[i].start); +if (error <0 ) { dev_err(parent_dev, "Invalid MC offset: %#x (for %s.%d\'s region %d)\n",@@ -504,6 +512,8 @@ static int fsl_mc_device_get_mmio_regions(struct fsl_mc_device *mc_dev, regions[i].flags =IORESOURCE_IO ;if (region_desc.flags &DPRC_REGION_CACHEABLE ) regions[i].flags |=IORESOURCE_CACHEABLE ; +if (region_desc.flags &DPRC_REGION_SHAREABLE ) + regions[i].flags |=IORESOURCE_MEM ; } mc_dev->regions = regions;drivers/bus/fsl-mc/fsl-mc-private.h +2
-0@@ -79,9 +79,11 @@ 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_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)/* DPRC command IDs */ #define DPRC_CMDID_CLOSE DPRC_CMD(0x800)
drivers/bus/fsl-mc/fsl-mc-private.h int dpmcp_reset(struct fsl_mc_io *mc_io, · line 104
Quoted 5 lines
drivers/bus/fsl-mc/fsl-mc-private.h +1
-1@@ -99,7 +101,7 @@ int dpmcp_reset(struct fsl_mc_io *mc_io,#define DPRC_CMDID_GET_CONT_ID DPRC_CMD(0x830)#define DPRC_CMDID_GET_OBJ_COUNT DPRC_CMD(0x159)#define DPRC_CMDID_GET_OBJ DPRC_CMD(0x15A) -#define DPRC_CMDID_GET_OBJ_REG DPRC_CMD(0x15E) +#define DPRC_CMDID_GET_OBJ_REG DPRC_CMD_V2(0x15E)
I see you're bumping this command's version to v2. Will we still be compatible with older MC firmware versions?
---
Best Regards, Laurentiu