aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandre Bounine <alexandre.bounine@idt.com>2016-08-02 17:06:54 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-08-02 19:35:37 -0400
commita057a52e94e15d89be8af557584e0144a496b6c6 (patch)
tree94f430671c0aacbb4613eddcf2b349082d8b0e30
parent60e377b5c1226d6737786947d0e915ab45d7f188 (diff)
rapidio: change inbound window size type to u64
Current definition of map_inb() mport operations callback uses u32 type to specify required inbound window (IBW) size. This is limiting factor because existing hardware - tsi721 and fsl_rio, both support IBW size up to 16GB. Changing type of size parameter to u64 to allow IBW size configurations larger than 4GB. [alexandre.bounine@idt.com: remove compiler warning about size of constant] Link: http://lkml.kernel.org/r/20160802184856.2566-1-alexandre.bounine@idt.com Link: http://lkml.kernel.org/r/1469125134-16523-11-git-send-email-alexandre.bounine@idt.com Signed-off-by: Alexandre Bounine <alexandre.bounine@idt.com> Cc: Matt Porter <mporter@kernel.crashing.org> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Andre van Herk <andre.van.herk@prodrive-technologies.com> Cc: Barry Wood <barry.wood@idt.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--arch/powerpc/sysdev/fsl_rio.c4
-rw-r--r--drivers/rapidio/devices/tsi721.c14
-rw-r--r--include/linux/rio.h2
3 files changed, 12 insertions, 8 deletions
diff --git a/arch/powerpc/sysdev/fsl_rio.c b/arch/powerpc/sysdev/fsl_rio.c
index f5bf38b94595..386790cfa16e 100644
--- a/arch/powerpc/sysdev/fsl_rio.c
+++ b/arch/powerpc/sysdev/fsl_rio.c
@@ -289,7 +289,7 @@ static void fsl_rio_inbound_mem_init(struct rio_priv *priv)
289} 289}
290 290
291int fsl_map_inb_mem(struct rio_mport *mport, dma_addr_t lstart, 291int fsl_map_inb_mem(struct rio_mport *mport, dma_addr_t lstart,
292 u64 rstart, u32 size, u32 flags) 292 u64 rstart, u64 size, u32 flags)
293{ 293{
294 struct rio_priv *priv = mport->priv; 294 struct rio_priv *priv = mport->priv;
295 u32 base_size; 295 u32 base_size;
@@ -298,7 +298,7 @@ int fsl_map_inb_mem(struct rio_mport *mport, dma_addr_t lstart,
298 u32 riwar; 298 u32 riwar;
299 int i; 299 int i;
300 300
301 if ((size & (size - 1)) != 0) 301 if ((size & (size - 1)) != 0 || size > 0x400000000ULL)
302 return -EINVAL; 302 return -EINVAL;
303 303
304 base_size_log = ilog2(size); 304 base_size_log = ilog2(size);
diff --git a/drivers/rapidio/devices/tsi721.c b/drivers/rapidio/devices/tsi721.c
index 8e07cd56abdc..53daf634a1ac 100644
--- a/drivers/rapidio/devices/tsi721.c
+++ b/drivers/rapidio/devices/tsi721.c
@@ -1090,7 +1090,7 @@ static void tsi721_init_pc2sr_mapping(struct tsi721_device *priv)
1090 * from rstart to lstart. 1090 * from rstart to lstart.
1091 */ 1091 */
1092static int tsi721_rio_map_inb_mem(struct rio_mport *mport, dma_addr_t lstart, 1092static int tsi721_rio_map_inb_mem(struct rio_mport *mport, dma_addr_t lstart,
1093 u64 rstart, u32 size, u32 flags) 1093 u64 rstart, u64 size, u32 flags)
1094{ 1094{
1095 struct tsi721_device *priv = mport->priv; 1095 struct tsi721_device *priv = mport->priv;
1096 int i, avail = -1; 1096 int i, avail = -1;
@@ -1103,6 +1103,10 @@ static int tsi721_rio_map_inb_mem(struct rio_mport *mport, dma_addr_t lstart,
1103 struct tsi721_ib_win_mapping *map = NULL; 1103 struct tsi721_ib_win_mapping *map = NULL;
1104 int ret = -EBUSY; 1104 int ret = -EBUSY;
1105 1105
1106 /* Max IBW size supported by HW is 16GB */
1107 if (size > 0x400000000UL)
1108 return -EINVAL;
1109
1106 if (direct) { 1110 if (direct) {
1107 /* Calculate minimal acceptable window size and base address */ 1111 /* Calculate minimal acceptable window size and base address */
1108 1112
@@ -1110,15 +1114,15 @@ static int tsi721_rio_map_inb_mem(struct rio_mport *mport, dma_addr_t lstart,
1110 ibw_start = lstart & ~(ibw_size - 1); 1114 ibw_start = lstart & ~(ibw_size - 1);
1111 1115
1112 tsi_debug(IBW, &priv->pdev->dev, 1116 tsi_debug(IBW, &priv->pdev->dev,
1113 "Direct (RIO_0x%llx -> PCIe_%pad), size=0x%x, ibw_start = 0x%llx", 1117 "Direct (RIO_0x%llx -> PCIe_%pad), size=0x%llx, ibw_start = 0x%llx",
1114 rstart, &lstart, size, ibw_start); 1118 rstart, &lstart, size, ibw_start);
1115 1119
1116 while ((lstart + size) > (ibw_start + ibw_size)) { 1120 while ((lstart + size) > (ibw_start + ibw_size)) {
1117 ibw_size *= 2; 1121 ibw_size *= 2;
1118 ibw_start = lstart & ~(ibw_size - 1); 1122 ibw_start = lstart & ~(ibw_size - 1);
1119 if (ibw_size > 0x80000000) { /* Limit max size to 2GB */ 1123 /* Check for crossing IBW max size 16GB */
1124 if (ibw_size > 0x400000000UL)
1120 return -EBUSY; 1125 return -EBUSY;
1121 }
1122 } 1126 }
1123 1127
1124 loc_start = ibw_start; 1128 loc_start = ibw_start;
@@ -1129,7 +1133,7 @@ static int tsi721_rio_map_inb_mem(struct rio_mport *mport, dma_addr_t lstart,
1129 1133
1130 } else { 1134 } else {
1131 tsi_debug(IBW, &priv->pdev->dev, 1135 tsi_debug(IBW, &priv->pdev->dev,
1132 "Translated (RIO_0x%llx -> PCIe_%pad), size=0x%x", 1136 "Translated (RIO_0x%llx -> PCIe_%pad), size=0x%llx",
1133 rstart, &lstart, size); 1137 rstart, &lstart, size);
1134 1138
1135 if (!is_power_of_2(size) || size < 0x1000 || 1139 if (!is_power_of_2(size) || size < 0x1000 ||
diff --git a/include/linux/rio.h b/include/linux/rio.h
index aa2323893e8d..f7ec35b48800 100644
--- a/include/linux/rio.h
+++ b/include/linux/rio.h
@@ -425,7 +425,7 @@ struct rio_ops {
425 int (*add_inb_buffer)(struct rio_mport *mport, int mbox, void *buf); 425 int (*add_inb_buffer)(struct rio_mport *mport, int mbox, void *buf);
426 void *(*get_inb_message)(struct rio_mport *mport, int mbox); 426 void *(*get_inb_message)(struct rio_mport *mport, int mbox);
427 int (*map_inb)(struct rio_mport *mport, dma_addr_t lstart, 427 int (*map_inb)(struct rio_mport *mport, dma_addr_t lstart,
428 u64 rstart, u32 size, u32 flags); 428 u64 rstart, u64 size, u32 flags);
429 void (*unmap_inb)(struct rio_mport *mport, dma_addr_t lstart); 429 void (*unmap_inb)(struct rio_mport *mport, dma_addr_t lstart);
430 int (*query_mport)(struct rio_mport *mport, 430 int (*query_mport)(struct rio_mport *mport,
431 struct rio_mport_attr *attr); 431 struct rio_mport_attr *attr);