All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Add DMA handle implementation
@ 2021-11-29  5:28 Jeya R
  2021-11-29  5:28 ` [PATCH 1/2] misc: fastrpc: Add fdlist implementation Jeya R
  2021-11-29  5:28 ` [PATCH 2/2] misc: fastrpc: Add dma handle implementation Jeya R
  0 siblings, 2 replies; 19+ messages in thread
From: Jeya R @ 2021-11-29  5:28 UTC (permalink / raw)
  To: linux-arm-msm, srinivas.kandagatla
  Cc: Jeya R, gregkh, linux-kernel, fastrpc.upstream

DMA handle is passed in an RPC call. When call reaches DSP,the fd is
added to DSP user process fd list. To unmap any DMA handle, DSP request
for unmap of fd and add it to fdlist which is then freed by driver when
call is returned from DSP.

Jeya R (2):
  misc: fastrpc: Add fdlist implementation
  misc: fastrpc: Add dma handle implementation

 drivers/misc/fastrpc.c | 97 ++++++++++++++++++++++++++++++++++++++------------
 1 file changed, 75 insertions(+), 22 deletions(-)

-- 
2.7.4


^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 1/2] misc: fastrpc: Add fdlist implementation
  2021-11-29  5:28 [PATCH 0/2] Add DMA handle implementation Jeya R
@ 2021-11-29  5:28 ` Jeya R
  2021-11-29  7:40     ` kernel test robot
                     ` (2 more replies)
  2021-11-29  5:28 ` [PATCH 2/2] misc: fastrpc: Add dma handle implementation Jeya R
  1 sibling, 3 replies; 19+ messages in thread
From: Jeya R @ 2021-11-29  5:28 UTC (permalink / raw)
  To: linux-arm-msm, srinivas.kandagatla
  Cc: Jeya R, gregkh, linux-kernel, fastrpc.upstream

Add fdlist implementation to support dma handles. fdlist is populated
by DSP if any map is no longer used and it is freed during put_args.

Signed-off-by: Jeya R <jeyr@codeaurora.org>
---
 drivers/misc/fastrpc.c | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index 39aca77..3c937ff 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -353,7 +353,7 @@ static void fastrpc_context_free(struct kref *ref)
 	ctx = container_of(ref, struct fastrpc_invoke_ctx, refcount);
 	cctx = ctx->cctx;
 
-	for (i = 0; i < ctx->nscalars; i++)
+	for (i = 0; i < ctx->nbufs; i++)
 		fastrpc_map_put(ctx->maps[i]);
 
 	if (ctx->buf)
@@ -785,6 +785,7 @@ static int fastrpc_get_args(u32 kernel, struct fastrpc_invoke_ctx *ctx)
 	err = fastrpc_buf_alloc(ctx->fl, dev, pkt_size, &ctx->buf);
 	if (err)
 		return err;
+	memset(ctx->buf->virt, 0, pkt_size);
 
 	rpra = ctx->buf->virt;
 	list = ctx->buf->virt + ctx->nscalars * sizeof(*rpra);
@@ -887,9 +888,19 @@ static int fastrpc_put_args(struct fastrpc_invoke_ctx *ctx,
 			    u32 kernel)
 {
 	struct fastrpc_remote_arg *rpra = ctx->rpra;
-	int i, inbufs;
+	struct fastrpc_map *mmap = NULL;
+	struct fastrpc_invoke_buf *list;
+	struct fastrpc_phy_page *pages;
+	u64 *fdlist;
+	int i, inbufs, outbufs, handles;
 
 	inbufs = REMOTE_SCALARS_INBUFS(ctx->sc);
+	outbufs = REMOTE_SCALARS_OUTBUFS(ctx->sc);
+	handles = REMOTE_SCALARS_INHANDLES(ctx->sc) + REMOTE_SCALARS_OUTHANDLES(ctx->sc);
+	list = ctx->buf->virt + ctx->nscalars * sizeof(*rpra);
+	pages = ctx->buf->virt + ctx->nscalars * (sizeof(*list) +
+		sizeof(*rpra));
+	fdlist = (uint64_t *)(pages + inbufs + outbufs + handles);
 
 	for (i = inbufs; i < ctx->nbufs; ++i) {
 		if (!ctx->maps[i]) {
@@ -906,6 +917,13 @@ static int fastrpc_put_args(struct fastrpc_invoke_ctx *ctx,
 		}
 	}
 
+	for (i = 0; i < FASTRPC_MAX_FDLIST; i++) {
+		if (!fdlist[i])
+			break;
+		if (!fastrpc_map_find(fl, (int)fdlist[i], &mmap))
+			fastrpc_map_put(mmap);
+	}
+
 	return 0;
 }
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 2/2] misc: fastrpc: Add dma handle implementation
  2021-11-29  5:28 [PATCH 0/2] Add DMA handle implementation Jeya R
  2021-11-29  5:28 ` [PATCH 1/2] misc: fastrpc: Add fdlist implementation Jeya R
@ 2021-11-29  5:28 ` Jeya R
  2021-11-29  8:00     ` kernel test robot
  2021-11-29  9:21     ` kernel test robot
  1 sibling, 2 replies; 19+ messages in thread
From: Jeya R @ 2021-11-29  5:28 UTC (permalink / raw)
  To: linux-arm-msm, srinivas.kandagatla
  Cc: Jeya R, gregkh, linux-kernel, fastrpc.upstream

Add dma handle instructions to remote arguments.

Signed-off-by: Jeya R <jeyr@codeaurora.org>
---
 drivers/misc/fastrpc.c | 75 ++++++++++++++++++++++++++++++++++++--------------
 1 file changed, 55 insertions(+), 20 deletions(-)

diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index 3c937ff..77071ee3 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -92,9 +92,20 @@ struct fastrpc_invoke_buf {
 	u32 pgidx;		/* index to start of contiguous region */
 };
 
-struct fastrpc_remote_arg {
-	u64 pv;
-	u64 len;
+struct fastrpc_remote_dmahandle {
+	s32 fd;			/* dma handle fd */
+	u32 offset;		/* dma handle offset */
+	u32 len;		/* dma handle length */
+};
+
+struct fastrpc_remote_buf {
+	u64 pv;			/* buffer pointer */
+	u64 len;		/* length of buffer */
+};
+
+union fastrpc_remote_arg {
+	struct fastrpc_remote_buf buf;
+	struct fastrpc_remote_dmahandle dma;
 };
 
 struct fastrpc_mmap_rsp_msg {
@@ -189,7 +200,7 @@ struct fastrpc_invoke_ctx {
 	struct work_struct put_work;
 	struct fastrpc_msg msg;
 	struct fastrpc_user *fl;
-	struct fastrpc_remote_arg *rpra;
+	union fastrpc_remote_arg *rpra;
 	struct fastrpc_map **maps;
 	struct fastrpc_buf *buf;
 	struct fastrpc_invoke_args *args;
@@ -760,12 +771,26 @@ static int fastrpc_create_maps(struct fastrpc_invoke_ctx *ctx)
 	return 0;
 }
 
+static struct fastrpc_invoke_buf *fastrpc_invoke_buf_start(union fastrpc_remote_arg *pra, u32 sc)
+{
+	unsigned int len = REMOTE_SCALARS_LENGTH(sc);
+
+	return (struct fastrpc_invoke_buf *)(&pra[len]);
+}
+
+static struct fastrpc_phy_page *fastrpc_phy_page_start(u32 sc, struct fastrpc_invoke_buf *buf)
+{
+	unsigned int len = REMOTE_SCALARS_LENGTH(sc);
+
+	return (struct fastrpc_phy_page *)(&buf[len]);
+}
+
 static int fastrpc_get_args(u32 kernel, struct fastrpc_invoke_ctx *ctx)
 {
 	struct device *dev = ctx->fl->sctx->dev;
-	struct fastrpc_remote_arg *rpra;
+	union fastrpc_remote_arg *rpra = NULL;
 	struct fastrpc_invoke_buf *list;
-	struct fastrpc_phy_page *pages;
+	struct fastrpc_phy_page *pages, *ipage;
 	int inbufs, i, oix, err = 0;
 	u64 len, rlen, pkt_size;
 	u64 pg_start, pg_end;
@@ -773,7 +798,13 @@ static int fastrpc_get_args(u32 kernel, struct fastrpc_invoke_ctx *ctx)
 	int metalen;
 
 	inbufs = REMOTE_SCALARS_INBUFS(ctx->sc);
-	metalen = fastrpc_get_meta_size(ctx);
+	list = fastrpc_invoke_buf_start(rpra, ctx->sc);
+	pages = fastrpc_phy_page_start(ctx->sc, list);
+	ipage = pages;
+	ipage += ctx->nscalars;
+	metalen = (size_t)&ipage[0] +
+		sizeof(u64) * FASTRPC_MAX_FDLIST +
+		sizeof(u32) * FASTRPC_MAX_CRCLIST;
 	pkt_size = fastrpc_get_payload_size(ctx, metalen);
 
 	err = fastrpc_create_maps(ctx);
@@ -788,12 +819,11 @@ static int fastrpc_get_args(u32 kernel, struct fastrpc_invoke_ctx *ctx)
 	memset(ctx->buf->virt, 0, pkt_size);
 
 	rpra = ctx->buf->virt;
-	list = ctx->buf->virt + ctx->nscalars * sizeof(*rpra);
-	pages = ctx->buf->virt + ctx->nscalars * (sizeof(*list) +
-		sizeof(*rpra));
+	ctx->rpra = rpra;
+	list = fastrpc_invoke_buf_start(rpra, ctx->sc);
+	pages = fastrpc_phy_page_start(ctx->sc, list);
 	args = (uintptr_t)ctx->buf->virt + metalen;
 	rlen = pkt_size - metalen;
-	ctx->rpra = rpra;
 
 	for (oix = 0; oix < ctx->nbufs; ++oix) {
 		int mlen;
@@ -801,8 +831,8 @@ static int fastrpc_get_args(u32 kernel, struct fastrpc_invoke_ctx *ctx)
 		i = ctx->olaps[oix].raix;
 		len = ctx->args[i].length;
 
-		rpra[i].pv = 0;
-		rpra[i].len = len;
+		rpra[i].buf.pv = 0;
+		rpra[i].buf.len = len;
 		list[i].num = len ? 1 : 0;
 		list[i].pgidx = i;
 
@@ -812,7 +842,7 @@ static int fastrpc_get_args(u32 kernel, struct fastrpc_invoke_ctx *ctx)
 		if (ctx->maps[i]) {
 			struct vm_area_struct *vma = NULL;
 
-			rpra[i].pv = (u64) ctx->args[i].ptr;
+			rpra[i].buf.pv = (u64) ctx->args[i].ptr;
 			pages[i].addr = ctx->maps[i]->phys;
 
 			mmap_read_lock(current->mm);
@@ -839,7 +869,7 @@ static int fastrpc_get_args(u32 kernel, struct fastrpc_invoke_ctx *ctx)
 			if (rlen < mlen)
 				goto bail;
 
-			rpra[i].pv = args - ctx->olaps[oix].offset;
+			rpra[i].buf.pv = args - ctx->olaps[oix].offset;
 			pages[i].addr = ctx->buf->phys -
 					ctx->olaps[oix].offset +
 					(pkt_size - rlen);
@@ -853,7 +883,7 @@ static int fastrpc_get_args(u32 kernel, struct fastrpc_invoke_ctx *ctx)
 		}
 
 		if (i < inbufs && !ctx->maps[i]) {
-			void *dst = (void *)(uintptr_t)rpra[i].pv;
+			void *dst = (void *)(uintptr_t)rpra[i].buf.pv;
 			void *src = (void *)(uintptr_t)ctx->args[i].ptr;
 
 			if (!kernel) {
@@ -869,12 +899,17 @@ static int fastrpc_get_args(u32 kernel, struct fastrpc_invoke_ctx *ctx)
 	}
 
 	for (i = ctx->nbufs; i < ctx->nscalars; ++i) {
-		rpra[i].pv = (u64) ctx->args[i].ptr;
-		rpra[i].len = ctx->args[i].length;
+		rpra[i].buf.pv = (u64) ctx->args[i].ptr;
+		rpra[i].buf.len = ctx->args[i].length;
 		list[i].num = ctx->args[i].length ? 1 : 0;
 		list[i].pgidx = i;
-		pages[i].addr = ctx->maps[i]->phys;
-		pages[i].size = ctx->maps[i]->size;
+		if (ctx->maps[i]) {
+			pages[i].addr = ctx->maps[i]->phys;
+			pages[i].size = ctx->maps[i]->size;
+		}
+		rpra[i].dma.fd = ctx->args[i].fd;
+		rpra[i].dma.len = ctx->args[i].length;
+		rpra[i].dma.offset = (u64) ctx->args[i].ptr;
 	}
 
 bail:
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* Re: [PATCH 1/2] misc: fastrpc: Add fdlist implementation
  2021-11-29  5:28 ` [PATCH 1/2] misc: fastrpc: Add fdlist implementation Jeya R
@ 2021-11-29  7:40     ` kernel test robot
  2021-11-29  8:00     ` kernel test robot
  2021-11-29 15:12   ` Srinivas Kandagatla
  2 siblings, 0 replies; 19+ messages in thread
From: kernel test robot @ 2021-11-29  7:40 UTC (permalink / raw)
  To: Jeya R, linux-arm-msm, srinivas.kandagatla
  Cc: llvm, kbuild-all, Jeya R, gregkh, linux-kernel, fastrpc.upstream

Hi Jeya,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on char-misc/char-misc-testing]
[also build test ERROR on v5.16-rc3 next-20211126]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Jeya-R/Add-DMA-handle-implementation/20211129-133228
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git cd455ebb748c4e198c8158e5d61b3034bf10f22b
config: hexagon-randconfig-r045-20211129 (https://download.01.org/0day-ci/archive/20211129/202111291504.10gwO8AE-lkp@intel.com/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project df08b2fe8b35cb63dfb3b49738a3494b9b4e6f8e)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/fda521c79abfc2f40115cb53cffb3a3886e8a2f9
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Jeya-R/Add-DMA-handle-implementation/20211129-133228
        git checkout fda521c79abfc2f40115cb53cffb3a3886e8a2f9
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash drivers/misc/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> drivers/misc/fastrpc.c:923:25: error: use of undeclared identifier 'fl'
                   if (!fastrpc_map_find(fl, (int)fdlist[i], &mmap))
                                         ^
   1 error generated.


vim +/fl +923 drivers/misc/fastrpc.c

   886	
   887	static int fastrpc_put_args(struct fastrpc_invoke_ctx *ctx,
   888				    u32 kernel)
   889	{
   890		struct fastrpc_remote_arg *rpra = ctx->rpra;
   891		struct fastrpc_map *mmap = NULL;
   892		struct fastrpc_invoke_buf *list;
   893		struct fastrpc_phy_page *pages;
   894		u64 *fdlist;
   895		int i, inbufs, outbufs, handles;
   896	
   897		inbufs = REMOTE_SCALARS_INBUFS(ctx->sc);
   898		outbufs = REMOTE_SCALARS_OUTBUFS(ctx->sc);
   899		handles = REMOTE_SCALARS_INHANDLES(ctx->sc) + REMOTE_SCALARS_OUTHANDLES(ctx->sc);
   900		list = ctx->buf->virt + ctx->nscalars * sizeof(*rpra);
   901		pages = ctx->buf->virt + ctx->nscalars * (sizeof(*list) +
   902			sizeof(*rpra));
   903		fdlist = (uint64_t *)(pages + inbufs + outbufs + handles);
   904	
   905		for (i = inbufs; i < ctx->nbufs; ++i) {
   906			if (!ctx->maps[i]) {
   907				void *src = (void *)(uintptr_t)rpra[i].pv;
   908				void *dst = (void *)(uintptr_t)ctx->args[i].ptr;
   909				u64 len = rpra[i].len;
   910	
   911				if (!kernel) {
   912					if (copy_to_user((void __user *)dst, src, len))
   913						return -EFAULT;
   914				} else {
   915					memcpy(dst, src, len);
   916				}
   917			}
   918		}
   919	
   920		for (i = 0; i < FASTRPC_MAX_FDLIST; i++) {
   921			if (!fdlist[i])
   922				break;
 > 923			if (!fastrpc_map_find(fl, (int)fdlist[i], &mmap))
   924				fastrpc_map_put(mmap);
   925		}
   926	
   927		return 0;
   928	}
   929	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 1/2] misc: fastrpc: Add fdlist implementation
@ 2021-11-29  7:40     ` kernel test robot
  0 siblings, 0 replies; 19+ messages in thread
From: kernel test robot @ 2021-11-29  7:40 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 3561 bytes --]

Hi Jeya,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on char-misc/char-misc-testing]
[also build test ERROR on v5.16-rc3 next-20211126]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Jeya-R/Add-DMA-handle-implementation/20211129-133228
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git cd455ebb748c4e198c8158e5d61b3034bf10f22b
config: hexagon-randconfig-r045-20211129 (https://download.01.org/0day-ci/archive/20211129/202111291504.10gwO8AE-lkp(a)intel.com/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project df08b2fe8b35cb63dfb3b49738a3494b9b4e6f8e)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/fda521c79abfc2f40115cb53cffb3a3886e8a2f9
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Jeya-R/Add-DMA-handle-implementation/20211129-133228
        git checkout fda521c79abfc2f40115cb53cffb3a3886e8a2f9
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash drivers/misc/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> drivers/misc/fastrpc.c:923:25: error: use of undeclared identifier 'fl'
                   if (!fastrpc_map_find(fl, (int)fdlist[i], &mmap))
                                         ^
   1 error generated.


vim +/fl +923 drivers/misc/fastrpc.c

   886	
   887	static int fastrpc_put_args(struct fastrpc_invoke_ctx *ctx,
   888				    u32 kernel)
   889	{
   890		struct fastrpc_remote_arg *rpra = ctx->rpra;
   891		struct fastrpc_map *mmap = NULL;
   892		struct fastrpc_invoke_buf *list;
   893		struct fastrpc_phy_page *pages;
   894		u64 *fdlist;
   895		int i, inbufs, outbufs, handles;
   896	
   897		inbufs = REMOTE_SCALARS_INBUFS(ctx->sc);
   898		outbufs = REMOTE_SCALARS_OUTBUFS(ctx->sc);
   899		handles = REMOTE_SCALARS_INHANDLES(ctx->sc) + REMOTE_SCALARS_OUTHANDLES(ctx->sc);
   900		list = ctx->buf->virt + ctx->nscalars * sizeof(*rpra);
   901		pages = ctx->buf->virt + ctx->nscalars * (sizeof(*list) +
   902			sizeof(*rpra));
   903		fdlist = (uint64_t *)(pages + inbufs + outbufs + handles);
   904	
   905		for (i = inbufs; i < ctx->nbufs; ++i) {
   906			if (!ctx->maps[i]) {
   907				void *src = (void *)(uintptr_t)rpra[i].pv;
   908				void *dst = (void *)(uintptr_t)ctx->args[i].ptr;
   909				u64 len = rpra[i].len;
   910	
   911				if (!kernel) {
   912					if (copy_to_user((void __user *)dst, src, len))
   913						return -EFAULT;
   914				} else {
   915					memcpy(dst, src, len);
   916				}
   917			}
   918		}
   919	
   920		for (i = 0; i < FASTRPC_MAX_FDLIST; i++) {
   921			if (!fdlist[i])
   922				break;
 > 923			if (!fastrpc_map_find(fl, (int)fdlist[i], &mmap))
   924				fastrpc_map_put(mmap);
   925		}
   926	
   927		return 0;
   928	}
   929	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 1/2] misc: fastrpc: Add fdlist implementation
  2021-11-29  5:28 ` [PATCH 1/2] misc: fastrpc: Add fdlist implementation Jeya R
@ 2021-11-29  8:00     ` kernel test robot
  2021-11-29  8:00     ` kernel test robot
  2021-11-29 15:12   ` Srinivas Kandagatla
  2 siblings, 0 replies; 19+ messages in thread
From: kernel test robot @ 2021-11-29  8:00 UTC (permalink / raw)
  To: Jeya R, linux-arm-msm, srinivas.kandagatla
  Cc: kbuild-all, Jeya R, gregkh, linux-kernel, fastrpc.upstream

Hi Jeya,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on char-misc/char-misc-testing]
[also build test ERROR on v5.16-rc3 next-20211126]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Jeya-R/Add-DMA-handle-implementation/20211129-133228
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git cd455ebb748c4e198c8158e5d61b3034bf10f22b
config: microblaze-randconfig-r031-20211128 (https://download.01.org/0day-ci/archive/20211129/202111291535.1s3d27nD-lkp@intel.com/config)
compiler: microblaze-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/fda521c79abfc2f40115cb53cffb3a3886e8a2f9
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Jeya-R/Add-DMA-handle-implementation/20211129-133228
        git checkout fda521c79abfc2f40115cb53cffb3a3886e8a2f9
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=microblaze SHELL=/bin/bash drivers/misc/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   drivers/misc/fastrpc.c: In function 'fastrpc_put_args':
>> drivers/misc/fastrpc.c:923:39: error: 'fl' undeclared (first use in this function); did you mean 'fd'?
     923 |                 if (!fastrpc_map_find(fl, (int)fdlist[i], &mmap))
         |                                       ^~
         |                                       fd
   drivers/misc/fastrpc.c:923:39: note: each undeclared identifier is reported only once for each function it appears in


vim +923 drivers/misc/fastrpc.c

   886	
   887	static int fastrpc_put_args(struct fastrpc_invoke_ctx *ctx,
   888				    u32 kernel)
   889	{
   890		struct fastrpc_remote_arg *rpra = ctx->rpra;
   891		struct fastrpc_map *mmap = NULL;
   892		struct fastrpc_invoke_buf *list;
   893		struct fastrpc_phy_page *pages;
   894		u64 *fdlist;
   895		int i, inbufs, outbufs, handles;
   896	
   897		inbufs = REMOTE_SCALARS_INBUFS(ctx->sc);
   898		outbufs = REMOTE_SCALARS_OUTBUFS(ctx->sc);
   899		handles = REMOTE_SCALARS_INHANDLES(ctx->sc) + REMOTE_SCALARS_OUTHANDLES(ctx->sc);
   900		list = ctx->buf->virt + ctx->nscalars * sizeof(*rpra);
   901		pages = ctx->buf->virt + ctx->nscalars * (sizeof(*list) +
   902			sizeof(*rpra));
   903		fdlist = (uint64_t *)(pages + inbufs + outbufs + handles);
   904	
   905		for (i = inbufs; i < ctx->nbufs; ++i) {
   906			if (!ctx->maps[i]) {
   907				void *src = (void *)(uintptr_t)rpra[i].pv;
   908				void *dst = (void *)(uintptr_t)ctx->args[i].ptr;
   909				u64 len = rpra[i].len;
   910	
   911				if (!kernel) {
   912					if (copy_to_user((void __user *)dst, src, len))
   913						return -EFAULT;
   914				} else {
   915					memcpy(dst, src, len);
   916				}
   917			}
   918		}
   919	
   920		for (i = 0; i < FASTRPC_MAX_FDLIST; i++) {
   921			if (!fdlist[i])
   922				break;
 > 923			if (!fastrpc_map_find(fl, (int)fdlist[i], &mmap))
   924				fastrpc_map_put(mmap);
   925		}
   926	
   927		return 0;
   928	}
   929	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 1/2] misc: fastrpc: Add fdlist implementation
@ 2021-11-29  8:00     ` kernel test robot
  0 siblings, 0 replies; 19+ messages in thread
From: kernel test robot @ 2021-11-29  8:00 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 3756 bytes --]

Hi Jeya,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on char-misc/char-misc-testing]
[also build test ERROR on v5.16-rc3 next-20211126]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Jeya-R/Add-DMA-handle-implementation/20211129-133228
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git cd455ebb748c4e198c8158e5d61b3034bf10f22b
config: microblaze-randconfig-r031-20211128 (https://download.01.org/0day-ci/archive/20211129/202111291535.1s3d27nD-lkp(a)intel.com/config)
compiler: microblaze-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/fda521c79abfc2f40115cb53cffb3a3886e8a2f9
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Jeya-R/Add-DMA-handle-implementation/20211129-133228
        git checkout fda521c79abfc2f40115cb53cffb3a3886e8a2f9
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=microblaze SHELL=/bin/bash drivers/misc/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   drivers/misc/fastrpc.c: In function 'fastrpc_put_args':
>> drivers/misc/fastrpc.c:923:39: error: 'fl' undeclared (first use in this function); did you mean 'fd'?
     923 |                 if (!fastrpc_map_find(fl, (int)fdlist[i], &mmap))
         |                                       ^~
         |                                       fd
   drivers/misc/fastrpc.c:923:39: note: each undeclared identifier is reported only once for each function it appears in


vim +923 drivers/misc/fastrpc.c

   886	
   887	static int fastrpc_put_args(struct fastrpc_invoke_ctx *ctx,
   888				    u32 kernel)
   889	{
   890		struct fastrpc_remote_arg *rpra = ctx->rpra;
   891		struct fastrpc_map *mmap = NULL;
   892		struct fastrpc_invoke_buf *list;
   893		struct fastrpc_phy_page *pages;
   894		u64 *fdlist;
   895		int i, inbufs, outbufs, handles;
   896	
   897		inbufs = REMOTE_SCALARS_INBUFS(ctx->sc);
   898		outbufs = REMOTE_SCALARS_OUTBUFS(ctx->sc);
   899		handles = REMOTE_SCALARS_INHANDLES(ctx->sc) + REMOTE_SCALARS_OUTHANDLES(ctx->sc);
   900		list = ctx->buf->virt + ctx->nscalars * sizeof(*rpra);
   901		pages = ctx->buf->virt + ctx->nscalars * (sizeof(*list) +
   902			sizeof(*rpra));
   903		fdlist = (uint64_t *)(pages + inbufs + outbufs + handles);
   904	
   905		for (i = inbufs; i < ctx->nbufs; ++i) {
   906			if (!ctx->maps[i]) {
   907				void *src = (void *)(uintptr_t)rpra[i].pv;
   908				void *dst = (void *)(uintptr_t)ctx->args[i].ptr;
   909				u64 len = rpra[i].len;
   910	
   911				if (!kernel) {
   912					if (copy_to_user((void __user *)dst, src, len))
   913						return -EFAULT;
   914				} else {
   915					memcpy(dst, src, len);
   916				}
   917			}
   918		}
   919	
   920		for (i = 0; i < FASTRPC_MAX_FDLIST; i++) {
   921			if (!fdlist[i])
   922				break;
 > 923			if (!fastrpc_map_find(fl, (int)fdlist[i], &mmap))
   924				fastrpc_map_put(mmap);
   925		}
   926	
   927		return 0;
   928	}
   929	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 2/2] misc: fastrpc: Add dma handle implementation
  2021-11-29  5:28 ` [PATCH 2/2] misc: fastrpc: Add dma handle implementation Jeya R
@ 2021-11-29  8:00     ` kernel test robot
  2021-11-29  9:21     ` kernel test robot
  1 sibling, 0 replies; 19+ messages in thread
From: kernel test robot @ 2021-11-29  8:00 UTC (permalink / raw)
  To: Jeya R, linux-arm-msm, srinivas.kandagatla
  Cc: llvm, kbuild-all, Jeya R, gregkh, linux-kernel, fastrpc.upstream

Hi Jeya,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on char-misc/char-misc-testing]
[also build test ERROR on v5.16-rc3 next-20211126]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Jeya-R/Add-DMA-handle-implementation/20211129-133228
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git cd455ebb748c4e198c8158e5d61b3034bf10f22b
config: hexagon-randconfig-r045-20211129 (https://download.01.org/0day-ci/archive/20211129/202111291504.W1SMyI4E-lkp@intel.com/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project df08b2fe8b35cb63dfb3b49738a3494b9b4e6f8e)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/d8e9cc594aeafa392d306e883c741b984b5fc89a
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Jeya-R/Add-DMA-handle-implementation/20211129-133228
        git checkout d8e9cc594aeafa392d306e883c741b984b5fc89a
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash drivers/misc/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> drivers/misc/fastrpc.c:721:17: error: use of 'fastrpc_remote_arg' with tag type that does not match previous declaration
           size = (sizeof(struct fastrpc_remote_arg) +
                          ^~~~~~
                          union
   drivers/misc/fastrpc.c:106:7: note: previous use is here
   union fastrpc_remote_arg {
         ^
   drivers/misc/fastrpc.c:925:2: error: use of 'fastrpc_remote_arg' with tag type that does not match previous declaration
           struct fastrpc_remote_arg *rpra = ctx->rpra;
           ^~~~~~
           union
   drivers/misc/fastrpc.c:106:7: note: previous use is here
   union fastrpc_remote_arg {
         ^
>> drivers/misc/fastrpc.c:942:43: error: no member named 'pv' in 'union fastrpc_remote_arg'
                           void *src = (void *)(uintptr_t)rpra[i].pv;
                                                          ~~~~~~~ ^
>> drivers/misc/fastrpc.c:944:22: error: no member named 'len' in 'union fastrpc_remote_arg'
                           u64 len = rpra[i].len;
                                     ~~~~~~~ ^
   drivers/misc/fastrpc.c:958:25: error: use of undeclared identifier 'fl'
                   if (!fastrpc_map_find(fl, (int)fdlist[i], &mmap))
                                         ^
   5 errors generated.


vim +/fastrpc_remote_arg +721 drivers/misc/fastrpc.c

c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  689  
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  690  /*
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  691   * Fastrpc payload buffer with metadata looks like:
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  692   *
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  693   * >>>>>>  START of METADATA <<<<<<<<<
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  694   * +---------------------------------+
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  695   * |           Arguments             |
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  696   * | type:(struct fastrpc_remote_arg)|
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  697   * |             (0 - N)             |
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  698   * +---------------------------------+
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  699   * |         Invoke Buffer list      |
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  700   * | type:(struct fastrpc_invoke_buf)|
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  701   * |           (0 - N)               |
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  702   * +---------------------------------+
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  703   * |         Page info list          |
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  704   * | type:(struct fastrpc_phy_page)  |
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  705   * |             (0 - N)             |
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  706   * +---------------------------------+
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  707   * |         Optional info           |
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  708   * |(can be specific to SoC/Firmware)|
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  709   * +---------------------------------+
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  710   * >>>>>>>>  END of METADATA <<<<<<<<<
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  711   * +---------------------------------+
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  712   * |         Inline ARGS             |
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  713   * |            (0-N)                |
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  714   * +---------------------------------+
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  715   */
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  716  
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  717  static int fastrpc_get_meta_size(struct fastrpc_invoke_ctx *ctx)
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  718  {
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  719  	int size = 0;
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  720  
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 @721  	size = (sizeof(struct fastrpc_remote_arg) +
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  722  		sizeof(struct fastrpc_invoke_buf) +
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  723  		sizeof(struct fastrpc_phy_page)) * ctx->nscalars +
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  724  		sizeof(u64) * FASTRPC_MAX_FDLIST +
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  725  		sizeof(u32) * FASTRPC_MAX_CRCLIST;
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  726  
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  727  	return size;
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  728  }
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  729  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 2/2] misc: fastrpc: Add dma handle implementation
@ 2021-11-29  8:00     ` kernel test robot
  0 siblings, 0 replies; 19+ messages in thread
From: kernel test robot @ 2021-11-29  8:00 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 6591 bytes --]

Hi Jeya,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on char-misc/char-misc-testing]
[also build test ERROR on v5.16-rc3 next-20211126]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Jeya-R/Add-DMA-handle-implementation/20211129-133228
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git cd455ebb748c4e198c8158e5d61b3034bf10f22b
config: hexagon-randconfig-r045-20211129 (https://download.01.org/0day-ci/archive/20211129/202111291504.W1SMyI4E-lkp(a)intel.com/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project df08b2fe8b35cb63dfb3b49738a3494b9b4e6f8e)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/d8e9cc594aeafa392d306e883c741b984b5fc89a
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Jeya-R/Add-DMA-handle-implementation/20211129-133228
        git checkout d8e9cc594aeafa392d306e883c741b984b5fc89a
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash drivers/misc/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> drivers/misc/fastrpc.c:721:17: error: use of 'fastrpc_remote_arg' with tag type that does not match previous declaration
           size = (sizeof(struct fastrpc_remote_arg) +
                          ^~~~~~
                          union
   drivers/misc/fastrpc.c:106:7: note: previous use is here
   union fastrpc_remote_arg {
         ^
   drivers/misc/fastrpc.c:925:2: error: use of 'fastrpc_remote_arg' with tag type that does not match previous declaration
           struct fastrpc_remote_arg *rpra = ctx->rpra;
           ^~~~~~
           union
   drivers/misc/fastrpc.c:106:7: note: previous use is here
   union fastrpc_remote_arg {
         ^
>> drivers/misc/fastrpc.c:942:43: error: no member named 'pv' in 'union fastrpc_remote_arg'
                           void *src = (void *)(uintptr_t)rpra[i].pv;
                                                          ~~~~~~~ ^
>> drivers/misc/fastrpc.c:944:22: error: no member named 'len' in 'union fastrpc_remote_arg'
                           u64 len = rpra[i].len;
                                     ~~~~~~~ ^
   drivers/misc/fastrpc.c:958:25: error: use of undeclared identifier 'fl'
                   if (!fastrpc_map_find(fl, (int)fdlist[i], &mmap))
                                         ^
   5 errors generated.


vim +/fastrpc_remote_arg +721 drivers/misc/fastrpc.c

c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  689  
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  690  /*
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  691   * Fastrpc payload buffer with metadata looks like:
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  692   *
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  693   * >>>>>>  START of METADATA <<<<<<<<<
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  694   * +---------------------------------+
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  695   * |           Arguments             |
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  696   * | type:(struct fastrpc_remote_arg)|
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  697   * |             (0 - N)             |
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  698   * +---------------------------------+
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  699   * |         Invoke Buffer list      |
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  700   * | type:(struct fastrpc_invoke_buf)|
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  701   * |           (0 - N)               |
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  702   * +---------------------------------+
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  703   * |         Page info list          |
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  704   * | type:(struct fastrpc_phy_page)  |
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  705   * |             (0 - N)             |
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  706   * +---------------------------------+
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  707   * |         Optional info           |
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  708   * |(can be specific to SoC/Firmware)|
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  709   * +---------------------------------+
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  710   * >>>>>>>>  END of METADATA <<<<<<<<<
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  711   * +---------------------------------+
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  712   * |         Inline ARGS             |
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  713   * |            (0-N)                |
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  714   * +---------------------------------+
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  715   */
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  716  
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  717  static int fastrpc_get_meta_size(struct fastrpc_invoke_ctx *ctx)
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  718  {
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  719  	int size = 0;
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  720  
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 @721  	size = (sizeof(struct fastrpc_remote_arg) +
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  722  		sizeof(struct fastrpc_invoke_buf) +
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  723  		sizeof(struct fastrpc_phy_page)) * ctx->nscalars +
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  724  		sizeof(u64) * FASTRPC_MAX_FDLIST +
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  725  		sizeof(u32) * FASTRPC_MAX_CRCLIST;
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  726  
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  727  	return size;
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  728  }
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  729  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 2/2] misc: fastrpc: Add dma handle implementation
  2021-11-29  5:28 ` [PATCH 2/2] misc: fastrpc: Add dma handle implementation Jeya R
@ 2021-11-29  9:21     ` kernel test robot
  2021-11-29  9:21     ` kernel test robot
  1 sibling, 0 replies; 19+ messages in thread
From: kernel test robot @ 2021-11-29  9:21 UTC (permalink / raw)
  To: Jeya R, linux-arm-msm, srinivas.kandagatla
  Cc: kbuild-all, Jeya R, gregkh, linux-kernel, fastrpc.upstream

Hi Jeya,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on char-misc/char-misc-testing]
[also build test ERROR on v5.16-rc3 next-20211126]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Jeya-R/Add-DMA-handle-implementation/20211129-133228
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git cd455ebb748c4e198c8158e5d61b3034bf10f22b
config: microblaze-randconfig-r031-20211128 (https://download.01.org/0day-ci/archive/20211129/202111291710.WVYQ9Aed-lkp@intel.com/config)
compiler: microblaze-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/d8e9cc594aeafa392d306e883c741b984b5fc89a
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Jeya-R/Add-DMA-handle-implementation/20211129-133228
        git checkout d8e9cc594aeafa392d306e883c741b984b5fc89a
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=microblaze SHELL=/bin/bash drivers/misc/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   drivers/misc/fastrpc.c: In function 'fastrpc_get_meta_size':
>> drivers/misc/fastrpc.c:721:31: error: 'fastrpc_remote_arg' defined as wrong kind of tag
     721 |         size = (sizeof(struct fastrpc_remote_arg) +
         |                               ^~~~~~~~~~~~~~~~~~
>> drivers/misc/fastrpc.c:721:24: error: invalid application of 'sizeof' to incomplete type 'struct fastrpc_remote_arg'
     721 |         size = (sizeof(struct fastrpc_remote_arg) +
         |                        ^~~~~~
   drivers/misc/fastrpc.c: In function 'fastrpc_put_args':
   drivers/misc/fastrpc.c:925:16: error: 'fastrpc_remote_arg' defined as wrong kind of tag
     925 |         struct fastrpc_remote_arg *rpra = ctx->rpra;
         |                ^~~~~~~~~~~~~~~~~~
>> drivers/misc/fastrpc.c:925:43: error: initialization of 'struct fastrpc_remote_arg *' from incompatible pointer type 'union fastrpc_remote_arg *' [-Werror=incompatible-pointer-types]
     925 |         struct fastrpc_remote_arg *rpra = ctx->rpra;
         |                                           ^~~
   drivers/misc/fastrpc.c:935:55: error: invalid application of 'sizeof' to incomplete type 'struct fastrpc_remote_arg'
     935 |         list = ctx->buf->virt + ctx->nscalars * sizeof(*rpra);
         |                                                       ^
   drivers/misc/fastrpc.c:937:23: error: invalid application of 'sizeof' to incomplete type 'struct fastrpc_remote_arg'
     937 |                 sizeof(*rpra));
         |                       ^
>> drivers/misc/fastrpc.c:942:60: error: invalid use of undefined type 'struct fastrpc_remote_arg'
     942 |                         void *src = (void *)(uintptr_t)rpra[i].pv;
         |                                                            ^
   drivers/misc/fastrpc.c:942:63: error: invalid use of undefined type 'struct fastrpc_remote_arg'
     942 |                         void *src = (void *)(uintptr_t)rpra[i].pv;
         |                                                               ^
   drivers/misc/fastrpc.c:944:39: error: invalid use of undefined type 'struct fastrpc_remote_arg'
     944 |                         u64 len = rpra[i].len;
         |                                       ^
   drivers/misc/fastrpc.c:944:42: error: invalid use of undefined type 'struct fastrpc_remote_arg'
     944 |                         u64 len = rpra[i].len;
         |                                          ^
   drivers/misc/fastrpc.c:958:39: error: 'fl' undeclared (first use in this function); did you mean 'fd'?
     958 |                 if (!fastrpc_map_find(fl, (int)fdlist[i], &mmap))
         |                                       ^~
         |                                       fd
   drivers/misc/fastrpc.c:958:39: note: each undeclared identifier is reported only once for each function it appears in
   At top level:
   drivers/misc/fastrpc.c:717:12: warning: 'fastrpc_get_meta_size' defined but not used [-Wunused-function]
     717 | static int fastrpc_get_meta_size(struct fastrpc_invoke_ctx *ctx)
         |            ^~~~~~~~~~~~~~~~~~~~~
   cc1: some warnings being treated as errors


vim +/fastrpc_remote_arg +721 drivers/misc/fastrpc.c

c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  689  
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  690  /*
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  691   * Fastrpc payload buffer with metadata looks like:
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  692   *
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  693   * >>>>>>  START of METADATA <<<<<<<<<
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  694   * +---------------------------------+
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  695   * |           Arguments             |
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  696   * | type:(struct fastrpc_remote_arg)|
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  697   * |             (0 - N)             |
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  698   * +---------------------------------+
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  699   * |         Invoke Buffer list      |
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  700   * | type:(struct fastrpc_invoke_buf)|
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  701   * |           (0 - N)               |
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  702   * +---------------------------------+
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  703   * |         Page info list          |
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  704   * | type:(struct fastrpc_phy_page)  |
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  705   * |             (0 - N)             |
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  706   * +---------------------------------+
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  707   * |         Optional info           |
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  708   * |(can be specific to SoC/Firmware)|
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  709   * +---------------------------------+
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  710   * >>>>>>>>  END of METADATA <<<<<<<<<
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  711   * +---------------------------------+
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  712   * |         Inline ARGS             |
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  713   * |            (0-N)                |
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  714   * +---------------------------------+
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  715   */
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  716  
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  717  static int fastrpc_get_meta_size(struct fastrpc_invoke_ctx *ctx)
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  718  {
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  719  	int size = 0;
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  720  
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 @721  	size = (sizeof(struct fastrpc_remote_arg) +
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  722  		sizeof(struct fastrpc_invoke_buf) +
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  723  		sizeof(struct fastrpc_phy_page)) * ctx->nscalars +
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  724  		sizeof(u64) * FASTRPC_MAX_FDLIST +
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  725  		sizeof(u32) * FASTRPC_MAX_CRCLIST;
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  726  
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  727  	return size;
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  728  }
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  729  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 2/2] misc: fastrpc: Add dma handle implementation
@ 2021-11-29  9:21     ` kernel test robot
  0 siblings, 0 replies; 19+ messages in thread
From: kernel test robot @ 2021-11-29  9:21 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 8405 bytes --]

Hi Jeya,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on char-misc/char-misc-testing]
[also build test ERROR on v5.16-rc3 next-20211126]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Jeya-R/Add-DMA-handle-implementation/20211129-133228
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git cd455ebb748c4e198c8158e5d61b3034bf10f22b
config: microblaze-randconfig-r031-20211128 (https://download.01.org/0day-ci/archive/20211129/202111291710.WVYQ9Aed-lkp(a)intel.com/config)
compiler: microblaze-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/d8e9cc594aeafa392d306e883c741b984b5fc89a
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Jeya-R/Add-DMA-handle-implementation/20211129-133228
        git checkout d8e9cc594aeafa392d306e883c741b984b5fc89a
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=microblaze SHELL=/bin/bash drivers/misc/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   drivers/misc/fastrpc.c: In function 'fastrpc_get_meta_size':
>> drivers/misc/fastrpc.c:721:31: error: 'fastrpc_remote_arg' defined as wrong kind of tag
     721 |         size = (sizeof(struct fastrpc_remote_arg) +
         |                               ^~~~~~~~~~~~~~~~~~
>> drivers/misc/fastrpc.c:721:24: error: invalid application of 'sizeof' to incomplete type 'struct fastrpc_remote_arg'
     721 |         size = (sizeof(struct fastrpc_remote_arg) +
         |                        ^~~~~~
   drivers/misc/fastrpc.c: In function 'fastrpc_put_args':
   drivers/misc/fastrpc.c:925:16: error: 'fastrpc_remote_arg' defined as wrong kind of tag
     925 |         struct fastrpc_remote_arg *rpra = ctx->rpra;
         |                ^~~~~~~~~~~~~~~~~~
>> drivers/misc/fastrpc.c:925:43: error: initialization of 'struct fastrpc_remote_arg *' from incompatible pointer type 'union fastrpc_remote_arg *' [-Werror=incompatible-pointer-types]
     925 |         struct fastrpc_remote_arg *rpra = ctx->rpra;
         |                                           ^~~
   drivers/misc/fastrpc.c:935:55: error: invalid application of 'sizeof' to incomplete type 'struct fastrpc_remote_arg'
     935 |         list = ctx->buf->virt + ctx->nscalars * sizeof(*rpra);
         |                                                       ^
   drivers/misc/fastrpc.c:937:23: error: invalid application of 'sizeof' to incomplete type 'struct fastrpc_remote_arg'
     937 |                 sizeof(*rpra));
         |                       ^
>> drivers/misc/fastrpc.c:942:60: error: invalid use of undefined type 'struct fastrpc_remote_arg'
     942 |                         void *src = (void *)(uintptr_t)rpra[i].pv;
         |                                                            ^
   drivers/misc/fastrpc.c:942:63: error: invalid use of undefined type 'struct fastrpc_remote_arg'
     942 |                         void *src = (void *)(uintptr_t)rpra[i].pv;
         |                                                               ^
   drivers/misc/fastrpc.c:944:39: error: invalid use of undefined type 'struct fastrpc_remote_arg'
     944 |                         u64 len = rpra[i].len;
         |                                       ^
   drivers/misc/fastrpc.c:944:42: error: invalid use of undefined type 'struct fastrpc_remote_arg'
     944 |                         u64 len = rpra[i].len;
         |                                          ^
   drivers/misc/fastrpc.c:958:39: error: 'fl' undeclared (first use in this function); did you mean 'fd'?
     958 |                 if (!fastrpc_map_find(fl, (int)fdlist[i], &mmap))
         |                                       ^~
         |                                       fd
   drivers/misc/fastrpc.c:958:39: note: each undeclared identifier is reported only once for each function it appears in
   At top level:
   drivers/misc/fastrpc.c:717:12: warning: 'fastrpc_get_meta_size' defined but not used [-Wunused-function]
     717 | static int fastrpc_get_meta_size(struct fastrpc_invoke_ctx *ctx)
         |            ^~~~~~~~~~~~~~~~~~~~~
   cc1: some warnings being treated as errors


vim +/fastrpc_remote_arg +721 drivers/misc/fastrpc.c

c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  689  
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  690  /*
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  691   * Fastrpc payload buffer with metadata looks like:
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  692   *
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  693   * >>>>>>  START of METADATA <<<<<<<<<
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  694   * +---------------------------------+
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  695   * |           Arguments             |
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  696   * | type:(struct fastrpc_remote_arg)|
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  697   * |             (0 - N)             |
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  698   * +---------------------------------+
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  699   * |         Invoke Buffer list      |
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  700   * | type:(struct fastrpc_invoke_buf)|
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  701   * |           (0 - N)               |
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  702   * +---------------------------------+
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  703   * |         Page info list          |
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  704   * | type:(struct fastrpc_phy_page)  |
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  705   * |             (0 - N)             |
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  706   * +---------------------------------+
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  707   * |         Optional info           |
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  708   * |(can be specific to SoC/Firmware)|
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  709   * +---------------------------------+
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  710   * >>>>>>>>  END of METADATA <<<<<<<<<
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  711   * +---------------------------------+
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  712   * |         Inline ARGS             |
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  713   * |            (0-N)                |
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  714   * +---------------------------------+
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  715   */
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  716  
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  717  static int fastrpc_get_meta_size(struct fastrpc_invoke_ctx *ctx)
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  718  {
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  719  	int size = 0;
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  720  
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08 @721  	size = (sizeof(struct fastrpc_remote_arg) +
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  722  		sizeof(struct fastrpc_invoke_buf) +
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  723  		sizeof(struct fastrpc_phy_page)) * ctx->nscalars +
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  724  		sizeof(u64) * FASTRPC_MAX_FDLIST +
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  725  		sizeof(u32) * FASTRPC_MAX_CRCLIST;
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  726  
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  727  	return size;
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  728  }
c68cfb718c8f97 Srinivas Kandagatla 2019-02-08  729  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 1/2] misc: fastrpc: Add fdlist implementation
  2021-11-29  5:28 ` [PATCH 1/2] misc: fastrpc: Add fdlist implementation Jeya R
  2021-11-29  7:40     ` kernel test robot
  2021-11-29  8:00     ` kernel test robot
@ 2021-11-29 15:12   ` Srinivas Kandagatla
  2 siblings, 0 replies; 19+ messages in thread
From: Srinivas Kandagatla @ 2021-11-29 15:12 UTC (permalink / raw)
  To: Jeya R, linux-arm-msm; +Cc: gregkh, linux-kernel, fastrpc.upstream

Thanks for the patch,


On 29/11/2021 05:28, Jeya R wrote:
> Add fdlist implementation to support dma handles. fdlist is populated
> by DSP if any map is no longer used and it is freed during put_args.

Does the dsp add all the fds (from in/out handles) to this list or only 
ones that are no-longer used by the dsp?


> 
> Signed-off-by: Jeya R <jeyr@codeaurora.org>
> ---
>   drivers/misc/fastrpc.c | 22 ++++++++++++++++++++--
>   1 file changed, 20 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
> index 39aca77..3c937ff 100644
> --- a/drivers/misc/fastrpc.c
> +++ b/drivers/misc/fastrpc.c
> @@ -353,7 +353,7 @@ static void fastrpc_context_free(struct kref *ref)
>   	ctx = container_of(ref, struct fastrpc_invoke_ctx, refcount);
>   	cctx = ctx->cctx;
>   
> -	for (i = 0; i < ctx->nscalars; i++)
> +	for (i = 0; i < ctx->nbufs; i++)
>   		fastrpc_map_put(ctx->maps[i]);

If above question is true, then who is going to free the rest of the 
scalars.

>   
>   	if (ctx->buf)
> @@ -785,6 +785,7 @@ static int fastrpc_get_args(u32 kernel, struct fastrpc_invoke_ctx *ctx)
>   	err = fastrpc_buf_alloc(ctx->fl, dev, pkt_size, &ctx->buf);
>   	if (err)
>   		return err;
> +	memset(ctx->buf->virt, 0, pkt_size);

Why do we need to make this zero, dma_alloc_coherent should have 
returned zeroed memory here anyway?


>   
>   	rpra = ctx->buf->virt;
>   	list = ctx->buf->virt + ctx->nscalars * sizeof(*rpra);
> @@ -887,9 +888,19 @@ static int fastrpc_put_args(struct fastrpc_invoke_ctx *ctx,
>   			    u32 kernel)
>   {
>   	struct fastrpc_remote_arg *rpra = ctx->rpra;
> -	int i, inbufs;
> +	struct fastrpc_map *mmap = NULL;
> +	struct fastrpc_invoke_buf *list;
> +	struct fastrpc_phy_page *pages;
> +	u64 *fdlist;
> +	int i, inbufs, outbufs, handles;
>   
>   	inbufs = REMOTE_SCALARS_INBUFS(ctx->sc);
> +	outbufs = REMOTE_SCALARS_OUTBUFS(ctx->sc);
> +	handles = REMOTE_SCALARS_INHANDLES(ctx->sc) + REMOTE_SCALARS_OUTHANDLES(ctx->sc);
> +	list = ctx->buf->virt + ctx->nscalars * sizeof(*rpra);
> +	pages = ctx->buf->virt + ctx->nscalars * (sizeof(*list) +
> +		sizeof(*rpra));
> +	fdlist = (uint64_t *)(pages + inbufs + outbufs + handles);
>   
>   	for (i = inbufs; i < ctx->nbufs; ++i) {
>   		if (!ctx->maps[i]) {
> @@ -906,6 +917,13 @@ static int fastrpc_put_args(struct fastrpc_invoke_ctx *ctx,
>   		}
>   	}
>   
> +	for (i = 0; i < FASTRPC_MAX_FDLIST; i++) {
> +		if (!fdlist[i])
> +			break;
> +		if (!fastrpc_map_find(fl, (int)fdlist[i], &mmap))

fastrpc_map_find() is will invoke a kref_get on the map so calling 
single fastrpc_map_put() here is not going to work. driver will be 
leaking memory.

Have you tested this patch with kmemleak enabled?

--srini


> +			fastrpc_map_put(mmap);


> +	}
> +
>   	return 0;
>   }
>   
> 

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 1/2] misc: fastrpc: Add fdlist implementation
  2021-11-30 12:57 ` [PATCH 1/2] misc: fastrpc: Add fdlist implementation Jeya R
@ 2021-11-30 23:52     ` kernel test robot
  2021-11-30 23:52     ` kernel test robot
  1 sibling, 0 replies; 19+ messages in thread
From: kernel test robot @ 2021-11-30 23:52 UTC (permalink / raw)
  To: Jeya R, linux-arm-msm, srinivas.kandagatla
  Cc: llvm, kbuild-all, Jeya R, gregkh, linux-kernel, fastrpc.upstream,
	bkumar, ekangupt, jeyr

Hi Jeya,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on char-misc/char-misc-testing]
[also build test ERROR on v5.16-rc3 next-20211130]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Jeya-R/misc-fastrpc-Add-fdlist-implementation/20211130-215833
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git 5d331b5922551637c586cdf5fdc1778910fc937f
config: hexagon-randconfig-r045-20211129 (https://download.01.org/0day-ci/archive/20211201/202112010754.IfnGCvD7-lkp@intel.com/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 25eb7fa01d7ebbe67648ea03841cda55b4239ab2)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/d9eaed76074c94c9751c3a587ef2409fa7ce153e
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Jeya-R/misc-fastrpc-Add-fdlist-implementation/20211130-215833
        git checkout d9eaed76074c94c9751c3a587ef2409fa7ce153e
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash drivers/misc/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> drivers/misc/fastrpc.c:923:25: error: use of undeclared identifier 'fl'
                   if (!fastrpc_map_find(fl, (int)fdlist[i], &mmap))
                                         ^
   1 error generated.


vim +/fl +923 drivers/misc/fastrpc.c

   886	
   887	static int fastrpc_put_args(struct fastrpc_invoke_ctx *ctx,
   888				    u32 kernel)
   889	{
   890		struct fastrpc_remote_arg *rpra = ctx->rpra;
   891		struct fastrpc_map *mmap = NULL;
   892		struct fastrpc_invoke_buf *list;
   893		struct fastrpc_phy_page *pages;
   894		u64 *fdlist;
   895		int i, inbufs, outbufs, handles;
   896	
   897		inbufs = REMOTE_SCALARS_INBUFS(ctx->sc);
   898		outbufs = REMOTE_SCALARS_OUTBUFS(ctx->sc);
   899		handles = REMOTE_SCALARS_INHANDLES(ctx->sc) + REMOTE_SCALARS_OUTHANDLES(ctx->sc);
   900		list = ctx->buf->virt + ctx->nscalars * sizeof(*rpra);
   901		pages = ctx->buf->virt + ctx->nscalars * (sizeof(*list) +
   902			sizeof(*rpra));
   903		fdlist = (uint64_t *)(pages + inbufs + outbufs + handles);
   904	
   905		for (i = inbufs; i < ctx->nbufs; ++i) {
   906			if (!ctx->maps[i]) {
   907				void *src = (void *)(uintptr_t)rpra[i].pv;
   908				void *dst = (void *)(uintptr_t)ctx->args[i].ptr;
   909				u64 len = rpra[i].len;
   910	
   911				if (!kernel) {
   912					if (copy_to_user((void __user *)dst, src, len))
   913						return -EFAULT;
   914				} else {
   915					memcpy(dst, src, len);
   916				}
   917			}
   918		}
   919	
   920		for (i = 0; i < FASTRPC_MAX_FDLIST; i++) {
   921			if (!fdlist[i])
   922				break;
 > 923			if (!fastrpc_map_find(fl, (int)fdlist[i], &mmap))
   924				fastrpc_map_put(mmap);
   925		}
   926	
   927		return 0;
   928	}
   929	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 1/2] misc: fastrpc: Add fdlist implementation
@ 2021-11-30 23:52     ` kernel test robot
  0 siblings, 0 replies; 19+ messages in thread
From: kernel test robot @ 2021-11-30 23:52 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 3579 bytes --]

Hi Jeya,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on char-misc/char-misc-testing]
[also build test ERROR on v5.16-rc3 next-20211130]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Jeya-R/misc-fastrpc-Add-fdlist-implementation/20211130-215833
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git 5d331b5922551637c586cdf5fdc1778910fc937f
config: hexagon-randconfig-r045-20211129 (https://download.01.org/0day-ci/archive/20211201/202112010754.IfnGCvD7-lkp(a)intel.com/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 25eb7fa01d7ebbe67648ea03841cda55b4239ab2)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/d9eaed76074c94c9751c3a587ef2409fa7ce153e
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Jeya-R/misc-fastrpc-Add-fdlist-implementation/20211130-215833
        git checkout d9eaed76074c94c9751c3a587ef2409fa7ce153e
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash drivers/misc/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> drivers/misc/fastrpc.c:923:25: error: use of undeclared identifier 'fl'
                   if (!fastrpc_map_find(fl, (int)fdlist[i], &mmap))
                                         ^
   1 error generated.


vim +/fl +923 drivers/misc/fastrpc.c

   886	
   887	static int fastrpc_put_args(struct fastrpc_invoke_ctx *ctx,
   888				    u32 kernel)
   889	{
   890		struct fastrpc_remote_arg *rpra = ctx->rpra;
   891		struct fastrpc_map *mmap = NULL;
   892		struct fastrpc_invoke_buf *list;
   893		struct fastrpc_phy_page *pages;
   894		u64 *fdlist;
   895		int i, inbufs, outbufs, handles;
   896	
   897		inbufs = REMOTE_SCALARS_INBUFS(ctx->sc);
   898		outbufs = REMOTE_SCALARS_OUTBUFS(ctx->sc);
   899		handles = REMOTE_SCALARS_INHANDLES(ctx->sc) + REMOTE_SCALARS_OUTHANDLES(ctx->sc);
   900		list = ctx->buf->virt + ctx->nscalars * sizeof(*rpra);
   901		pages = ctx->buf->virt + ctx->nscalars * (sizeof(*list) +
   902			sizeof(*rpra));
   903		fdlist = (uint64_t *)(pages + inbufs + outbufs + handles);
   904	
   905		for (i = inbufs; i < ctx->nbufs; ++i) {
   906			if (!ctx->maps[i]) {
   907				void *src = (void *)(uintptr_t)rpra[i].pv;
   908				void *dst = (void *)(uintptr_t)ctx->args[i].ptr;
   909				u64 len = rpra[i].len;
   910	
   911				if (!kernel) {
   912					if (copy_to_user((void __user *)dst, src, len))
   913						return -EFAULT;
   914				} else {
   915					memcpy(dst, src, len);
   916				}
   917			}
   918		}
   919	
   920		for (i = 0; i < FASTRPC_MAX_FDLIST; i++) {
   921			if (!fdlist[i])
   922				break;
 > 923			if (!fastrpc_map_find(fl, (int)fdlist[i], &mmap))
   924				fastrpc_map_put(mmap);
   925		}
   926	
   927		return 0;
   928	}
   929	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 1/2] misc: fastrpc: Add fdlist implementation
  2021-11-30 12:57 ` [PATCH 1/2] misc: fastrpc: Add fdlist implementation Jeya R
@ 2021-11-30 20:20     ` kernel test robot
  2021-11-30 23:52     ` kernel test robot
  1 sibling, 0 replies; 19+ messages in thread
From: kernel test robot @ 2021-11-30 20:20 UTC (permalink / raw)
  To: Jeya R, linux-arm-msm, srinivas.kandagatla
  Cc: kbuild-all, Jeya R, gregkh, linux-kernel, fastrpc.upstream,
	bkumar, ekangupt, jeyr

Hi Jeya,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on char-misc/char-misc-testing]
[also build test ERROR on v5.16-rc3 next-20211130]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Jeya-R/misc-fastrpc-Add-fdlist-implementation/20211130-215833
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git 5d331b5922551637c586cdf5fdc1778910fc937f
config: sh-allmodconfig (https://download.01.org/0day-ci/archive/20211201/202112010402.quLlpjqn-lkp@intel.com/config)
compiler: sh4-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/d9eaed76074c94c9751c3a587ef2409fa7ce153e
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Jeya-R/misc-fastrpc-Add-fdlist-implementation/20211130-215833
        git checkout d9eaed76074c94c9751c3a587ef2409fa7ce153e
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=sh SHELL=/bin/bash drivers/misc/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   drivers/misc/fastrpc.c: In function 'fastrpc_put_args':
>> drivers/misc/fastrpc.c:923:39: error: 'fl' undeclared (first use in this function); did you mean 'fd'?
     923 |                 if (!fastrpc_map_find(fl, (int)fdlist[i], &mmap))
         |                                       ^~
         |                                       fd
   drivers/misc/fastrpc.c:923:39: note: each undeclared identifier is reported only once for each function it appears in


vim +923 drivers/misc/fastrpc.c

   886	
   887	static int fastrpc_put_args(struct fastrpc_invoke_ctx *ctx,
   888				    u32 kernel)
   889	{
   890		struct fastrpc_remote_arg *rpra = ctx->rpra;
   891		struct fastrpc_map *mmap = NULL;
   892		struct fastrpc_invoke_buf *list;
   893		struct fastrpc_phy_page *pages;
   894		u64 *fdlist;
   895		int i, inbufs, outbufs, handles;
   896	
   897		inbufs = REMOTE_SCALARS_INBUFS(ctx->sc);
   898		outbufs = REMOTE_SCALARS_OUTBUFS(ctx->sc);
   899		handles = REMOTE_SCALARS_INHANDLES(ctx->sc) + REMOTE_SCALARS_OUTHANDLES(ctx->sc);
   900		list = ctx->buf->virt + ctx->nscalars * sizeof(*rpra);
   901		pages = ctx->buf->virt + ctx->nscalars * (sizeof(*list) +
   902			sizeof(*rpra));
   903		fdlist = (uint64_t *)(pages + inbufs + outbufs + handles);
   904	
   905		for (i = inbufs; i < ctx->nbufs; ++i) {
   906			if (!ctx->maps[i]) {
   907				void *src = (void *)(uintptr_t)rpra[i].pv;
   908				void *dst = (void *)(uintptr_t)ctx->args[i].ptr;
   909				u64 len = rpra[i].len;
   910	
   911				if (!kernel) {
   912					if (copy_to_user((void __user *)dst, src, len))
   913						return -EFAULT;
   914				} else {
   915					memcpy(dst, src, len);
   916				}
   917			}
   918		}
   919	
   920		for (i = 0; i < FASTRPC_MAX_FDLIST; i++) {
   921			if (!fdlist[i])
   922				break;
 > 923			if (!fastrpc_map_find(fl, (int)fdlist[i], &mmap))
   924				fastrpc_map_put(mmap);
   925		}
   926	
   927		return 0;
   928	}
   929	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 1/2] misc: fastrpc: Add fdlist implementation
@ 2021-11-30 20:20     ` kernel test robot
  0 siblings, 0 replies; 19+ messages in thread
From: kernel test robot @ 2021-11-30 20:20 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 3739 bytes --]

Hi Jeya,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on char-misc/char-misc-testing]
[also build test ERROR on v5.16-rc3 next-20211130]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Jeya-R/misc-fastrpc-Add-fdlist-implementation/20211130-215833
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git 5d331b5922551637c586cdf5fdc1778910fc937f
config: sh-allmodconfig (https://download.01.org/0day-ci/archive/20211201/202112010402.quLlpjqn-lkp(a)intel.com/config)
compiler: sh4-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/d9eaed76074c94c9751c3a587ef2409fa7ce153e
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Jeya-R/misc-fastrpc-Add-fdlist-implementation/20211130-215833
        git checkout d9eaed76074c94c9751c3a587ef2409fa7ce153e
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=sh SHELL=/bin/bash drivers/misc/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   drivers/misc/fastrpc.c: In function 'fastrpc_put_args':
>> drivers/misc/fastrpc.c:923:39: error: 'fl' undeclared (first use in this function); did you mean 'fd'?
     923 |                 if (!fastrpc_map_find(fl, (int)fdlist[i], &mmap))
         |                                       ^~
         |                                       fd
   drivers/misc/fastrpc.c:923:39: note: each undeclared identifier is reported only once for each function it appears in


vim +923 drivers/misc/fastrpc.c

   886	
   887	static int fastrpc_put_args(struct fastrpc_invoke_ctx *ctx,
   888				    u32 kernel)
   889	{
   890		struct fastrpc_remote_arg *rpra = ctx->rpra;
   891		struct fastrpc_map *mmap = NULL;
   892		struct fastrpc_invoke_buf *list;
   893		struct fastrpc_phy_page *pages;
   894		u64 *fdlist;
   895		int i, inbufs, outbufs, handles;
   896	
   897		inbufs = REMOTE_SCALARS_INBUFS(ctx->sc);
   898		outbufs = REMOTE_SCALARS_OUTBUFS(ctx->sc);
   899		handles = REMOTE_SCALARS_INHANDLES(ctx->sc) + REMOTE_SCALARS_OUTHANDLES(ctx->sc);
   900		list = ctx->buf->virt + ctx->nscalars * sizeof(*rpra);
   901		pages = ctx->buf->virt + ctx->nscalars * (sizeof(*list) +
   902			sizeof(*rpra));
   903		fdlist = (uint64_t *)(pages + inbufs + outbufs + handles);
   904	
   905		for (i = inbufs; i < ctx->nbufs; ++i) {
   906			if (!ctx->maps[i]) {
   907				void *src = (void *)(uintptr_t)rpra[i].pv;
   908				void *dst = (void *)(uintptr_t)ctx->args[i].ptr;
   909				u64 len = rpra[i].len;
   910	
   911				if (!kernel) {
   912					if (copy_to_user((void __user *)dst, src, len))
   913						return -EFAULT;
   914				} else {
   915					memcpy(dst, src, len);
   916				}
   917			}
   918		}
   919	
   920		for (i = 0; i < FASTRPC_MAX_FDLIST; i++) {
   921			if (!fdlist[i])
   922				break;
 > 923			if (!fastrpc_map_find(fl, (int)fdlist[i], &mmap))
   924				fastrpc_map_put(mmap);
   925		}
   926	
   927		return 0;
   928	}
   929	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 1/2] misc: fastrpc: Add fdlist implementation
  2021-11-30 12:54 ` [PATCH 1/2] misc: fastrpc: Add fdlist implementation Jeya R
@ 2021-11-30 13:12   ` Srinivas Kandagatla
  0 siblings, 0 replies; 19+ messages in thread
From: Srinivas Kandagatla @ 2021-11-30 13:12 UTC (permalink / raw)
  To: Jeya R, ekangupt, linux-arm-msm; +Cc: gregkh, linux-kernel, fastrpc.upstream

Hi Jeya,

This is version 2 of the patchset which is not reflected in the subject 
line.




On 30/11/2021 12:54, Jeya R wrote:
> Add fdlist implementation to support dma handles. fdlist is populated
> by DSP if any map is no longer used and it is freed during put_args.
> 
> Signed-off-by: Jeya R <jeyr@codeaurora.org>
> ---
>   drivers/misc/fastrpc.c | 22 ++++++++++++++++++++--
>   1 file changed, 20 insertions(+), 2 deletions(-)

Have you missed comments my comments on this patch

https://www.spinics.net/lists/linux-arm-msm/msg99023.html

--srini

> 
> diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
> index 39aca77..3c937ff 100644
> --- a/drivers/misc/fastrpc.c
> +++ b/drivers/misc/fastrpc.c
> @@ -353,7 +353,7 @@ static void fastrpc_context_free(struct kref *ref)
>   	ctx = container_of(ref, struct fastrpc_invoke_ctx, refcount);
>   	cctx = ctx->cctx;
>   
> -	for (i = 0; i < ctx->nscalars; i++)
> +	for (i = 0; i < ctx->nbufs; i++)
>   		fastrpc_map_put(ctx->maps[i]);
>   
>   	if (ctx->buf)
> @@ -785,6 +785,7 @@ static int fastrpc_get_args(u32 kernel, struct fastrpc_invoke_ctx *ctx)
>   	err = fastrpc_buf_alloc(ctx->fl, dev, pkt_size, &ctx->buf);
>   	if (err)
>   		return err;
> +	memset(ctx->buf->virt, 0, pkt_size);
>   
>   	rpra = ctx->buf->virt;
>   	list = ctx->buf->virt + ctx->nscalars * sizeof(*rpra);
> @@ -887,9 +888,19 @@ static int fastrpc_put_args(struct fastrpc_invoke_ctx *ctx,
>   			    u32 kernel)
>   {
>   	struct fastrpc_remote_arg *rpra = ctx->rpra;
> -	int i, inbufs;
> +	struct fastrpc_map *mmap = NULL;
> +	struct fastrpc_invoke_buf *list;
> +	struct fastrpc_phy_page *pages;
> +	u64 *fdlist;
> +	int i, inbufs, outbufs, handles;
>   
>   	inbufs = REMOTE_SCALARS_INBUFS(ctx->sc);
> +	outbufs = REMOTE_SCALARS_OUTBUFS(ctx->sc);
> +	handles = REMOTE_SCALARS_INHANDLES(ctx->sc) + REMOTE_SCALARS_OUTHANDLES(ctx->sc);
> +	list = ctx->buf->virt + ctx->nscalars * sizeof(*rpra);
> +	pages = ctx->buf->virt + ctx->nscalars * (sizeof(*list) +
> +		sizeof(*rpra));
> +	fdlist = (uint64_t *)(pages + inbufs + outbufs + handles);
>   
>   	for (i = inbufs; i < ctx->nbufs; ++i) {
>   		if (!ctx->maps[i]) {
> @@ -906,6 +917,13 @@ static int fastrpc_put_args(struct fastrpc_invoke_ctx *ctx,
>   		}
>   	}
>   
> +	for (i = 0; i < FASTRPC_MAX_FDLIST; i++) {
> +		if (!fdlist[i])
> +			break;
> +		if (!fastrpc_map_find(fl, (int)fdlist[i], &mmap))
> +			fastrpc_map_put(mmap);
> +	}
> +
>   	return 0;
>   }
>   
> 

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 1/2] misc: fastrpc: Add fdlist implementation
  2021-11-30 12:57 [PATCH 0/3] Add vmid property and mapping attribute Jeya R
@ 2021-11-30 12:57 ` Jeya R
  2021-11-30 20:20     ` kernel test robot
  2021-11-30 23:52     ` kernel test robot
  0 siblings, 2 replies; 19+ messages in thread
From: Jeya R @ 2021-11-30 12:57 UTC (permalink / raw)
  To: linux-arm-msm, srinivas.kandagatla
  Cc: Jeya R, gregkh, linux-kernel, fastrpc.upstream, bkumar, ekangupt, jeyr

Add fdlist implementation to support dma handles. fdlist is populated
by DSP if any map is no longer used and it is freed during put_args.

Signed-off-by: Jeya R <jeyr@codeaurora.org>
---
 drivers/misc/fastrpc.c | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index 39aca77..3c937ff 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -353,7 +353,7 @@ static void fastrpc_context_free(struct kref *ref)
 	ctx = container_of(ref, struct fastrpc_invoke_ctx, refcount);
 	cctx = ctx->cctx;
 
-	for (i = 0; i < ctx->nscalars; i++)
+	for (i = 0; i < ctx->nbufs; i++)
 		fastrpc_map_put(ctx->maps[i]);
 
 	if (ctx->buf)
@@ -785,6 +785,7 @@ static int fastrpc_get_args(u32 kernel, struct fastrpc_invoke_ctx *ctx)
 	err = fastrpc_buf_alloc(ctx->fl, dev, pkt_size, &ctx->buf);
 	if (err)
 		return err;
+	memset(ctx->buf->virt, 0, pkt_size);
 
 	rpra = ctx->buf->virt;
 	list = ctx->buf->virt + ctx->nscalars * sizeof(*rpra);
@@ -887,9 +888,19 @@ static int fastrpc_put_args(struct fastrpc_invoke_ctx *ctx,
 			    u32 kernel)
 {
 	struct fastrpc_remote_arg *rpra = ctx->rpra;
-	int i, inbufs;
+	struct fastrpc_map *mmap = NULL;
+	struct fastrpc_invoke_buf *list;
+	struct fastrpc_phy_page *pages;
+	u64 *fdlist;
+	int i, inbufs, outbufs, handles;
 
 	inbufs = REMOTE_SCALARS_INBUFS(ctx->sc);
+	outbufs = REMOTE_SCALARS_OUTBUFS(ctx->sc);
+	handles = REMOTE_SCALARS_INHANDLES(ctx->sc) + REMOTE_SCALARS_OUTHANDLES(ctx->sc);
+	list = ctx->buf->virt + ctx->nscalars * sizeof(*rpra);
+	pages = ctx->buf->virt + ctx->nscalars * (sizeof(*list) +
+		sizeof(*rpra));
+	fdlist = (uint64_t *)(pages + inbufs + outbufs + handles);
 
 	for (i = inbufs; i < ctx->nbufs; ++i) {
 		if (!ctx->maps[i]) {
@@ -906,6 +917,13 @@ static int fastrpc_put_args(struct fastrpc_invoke_ctx *ctx,
 		}
 	}
 
+	for (i = 0; i < FASTRPC_MAX_FDLIST; i++) {
+		if (!fdlist[i])
+			break;
+		if (!fastrpc_map_find(fl, (int)fdlist[i], &mmap))
+			fastrpc_map_put(mmap);
+	}
+
 	return 0;
 }
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 1/2] misc: fastrpc: Add fdlist implementation
       [not found] <1638276897-6146-1-git-send-email-jeyr@codeaurora.org>
@ 2021-11-30 12:54 ` Jeya R
  2021-11-30 13:12   ` Srinivas Kandagatla
  0 siblings, 1 reply; 19+ messages in thread
From: Jeya R @ 2021-11-30 12:54 UTC (permalink / raw)
  To: ekangupt, linux-arm-msm, srinivas.kandagatla
  Cc: Jeya R, gregkh, linux-kernel, fastrpc.upstream

Add fdlist implementation to support dma handles. fdlist is populated
by DSP if any map is no longer used and it is freed during put_args.

Signed-off-by: Jeya R <jeyr@codeaurora.org>
---
 drivers/misc/fastrpc.c | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index 39aca77..3c937ff 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -353,7 +353,7 @@ static void fastrpc_context_free(struct kref *ref)
 	ctx = container_of(ref, struct fastrpc_invoke_ctx, refcount);
 	cctx = ctx->cctx;
 
-	for (i = 0; i < ctx->nscalars; i++)
+	for (i = 0; i < ctx->nbufs; i++)
 		fastrpc_map_put(ctx->maps[i]);
 
 	if (ctx->buf)
@@ -785,6 +785,7 @@ static int fastrpc_get_args(u32 kernel, struct fastrpc_invoke_ctx *ctx)
 	err = fastrpc_buf_alloc(ctx->fl, dev, pkt_size, &ctx->buf);
 	if (err)
 		return err;
+	memset(ctx->buf->virt, 0, pkt_size);
 
 	rpra = ctx->buf->virt;
 	list = ctx->buf->virt + ctx->nscalars * sizeof(*rpra);
@@ -887,9 +888,19 @@ static int fastrpc_put_args(struct fastrpc_invoke_ctx *ctx,
 			    u32 kernel)
 {
 	struct fastrpc_remote_arg *rpra = ctx->rpra;
-	int i, inbufs;
+	struct fastrpc_map *mmap = NULL;
+	struct fastrpc_invoke_buf *list;
+	struct fastrpc_phy_page *pages;
+	u64 *fdlist;
+	int i, inbufs, outbufs, handles;
 
 	inbufs = REMOTE_SCALARS_INBUFS(ctx->sc);
+	outbufs = REMOTE_SCALARS_OUTBUFS(ctx->sc);
+	handles = REMOTE_SCALARS_INHANDLES(ctx->sc) + REMOTE_SCALARS_OUTHANDLES(ctx->sc);
+	list = ctx->buf->virt + ctx->nscalars * sizeof(*rpra);
+	pages = ctx->buf->virt + ctx->nscalars * (sizeof(*list) +
+		sizeof(*rpra));
+	fdlist = (uint64_t *)(pages + inbufs + outbufs + handles);
 
 	for (i = inbufs; i < ctx->nbufs; ++i) {
 		if (!ctx->maps[i]) {
@@ -906,6 +917,13 @@ static int fastrpc_put_args(struct fastrpc_invoke_ctx *ctx,
 		}
 	}
 
+	for (i = 0; i < FASTRPC_MAX_FDLIST; i++) {
+		if (!fdlist[i])
+			break;
+		if (!fastrpc_map_find(fl, (int)fdlist[i], &mmap))
+			fastrpc_map_put(mmap);
+	}
+
 	return 0;
 }
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2021-11-30 23:53 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-29  5:28 [PATCH 0/2] Add DMA handle implementation Jeya R
2021-11-29  5:28 ` [PATCH 1/2] misc: fastrpc: Add fdlist implementation Jeya R
2021-11-29  7:40   ` kernel test robot
2021-11-29  7:40     ` kernel test robot
2021-11-29  8:00   ` kernel test robot
2021-11-29  8:00     ` kernel test robot
2021-11-29 15:12   ` Srinivas Kandagatla
2021-11-29  5:28 ` [PATCH 2/2] misc: fastrpc: Add dma handle implementation Jeya R
2021-11-29  8:00   ` kernel test robot
2021-11-29  8:00     ` kernel test robot
2021-11-29  9:21   ` kernel test robot
2021-11-29  9:21     ` kernel test robot
     [not found] <1638276897-6146-1-git-send-email-jeyr@codeaurora.org>
2021-11-30 12:54 ` [PATCH 1/2] misc: fastrpc: Add fdlist implementation Jeya R
2021-11-30 13:12   ` Srinivas Kandagatla
2021-11-30 12:57 [PATCH 0/3] Add vmid property and mapping attribute Jeya R
2021-11-30 12:57 ` [PATCH 1/2] misc: fastrpc: Add fdlist implementation Jeya R
2021-11-30 20:20   ` kernel test robot
2021-11-30 20:20     ` kernel test robot
2021-11-30 23:52   ` kernel test robot
2021-11-30 23:52     ` kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.