Hi Ekansh,

kernel test robot noticed the following build errors:

[auto build test ERROR on char-misc/char-misc-testing]
[also build test ERROR on char-misc/char-misc-next char-misc/char-misc-linus 
linus/master v6.19 next-20260213]
[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#_base_tree_information]

url:    
https://github.com/intel-lab-lkp/linux/commits/Ekansh-Gupta/misc-fastrpc-Move-fdlist-to-invoke-context-structure/20260216-022305
base:   char-misc/char-misc-testing
patch link:    
https://lore.kernel.org/r/20260215182136.3995111-3-ekansh.gupta%40oss.qualcomm.com
patch subject: [PATCH v6 2/4] misc: fastrpc: Replace hardcoded ctxid mask with 
GENMASK
config: sh-allyesconfig 
(https://download.01.org/0day-ci/archive/20260216/[email protected]/config)
compiler: sh4-linux-gcc (GCC) 15.2.0
reproduce (this is a W=1 build): 
(https://download.01.org/0day-ci/archive/20260216/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: 
https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

   drivers/misc/fastrpc.c: In function 'fastrpc_context_free':
>> drivers/misc/fastrpc.c:518:36: error: implicit declaration of function 
>> 'FIELD_GET' [-Wimplicit-function-declaration]
     518 |         idr_remove(&cctx->ctx_idr, FIELD_GET(FASTRPC_CTXID_MASK, 
ctx->ctxid));
         |                                    ^~~~~~~~~
   drivers/misc/fastrpc.c: In function 'fastrpc_context_alloc':
>> drivers/misc/fastrpc.c:654:22: error: implicit declaration of function 
>> 'FIELD_PREP' [-Wimplicit-function-declaration]
     654 |         ctx->ctxid = FIELD_PREP(FASTRPC_CTXID_MASK, ret);
         |                      ^~~~~~~~~~


vim +/FIELD_GET +518 drivers/misc/fastrpc.c

   500  
   501  static void fastrpc_context_free(struct kref *ref)
   502  {
   503          struct fastrpc_invoke_ctx *ctx;
   504          struct fastrpc_channel_ctx *cctx;
   505          unsigned long flags;
   506          int i;
   507  
   508          ctx = container_of(ref, struct fastrpc_invoke_ctx, refcount);
   509          cctx = ctx->cctx;
   510  
   511          for (i = 0; i < ctx->nbufs; i++)
   512                  fastrpc_map_put(ctx->maps[i]);
   513  
   514          if (ctx->buf)
   515                  fastrpc_buf_free(ctx->buf);
   516  
   517          spin_lock_irqsave(&cctx->lock, flags);
 > 518          idr_remove(&cctx->ctx_idr, FIELD_GET(FASTRPC_CTXID_MASK, 
 > ctx->ctxid));
   519          spin_unlock_irqrestore(&cctx->lock, flags);
   520  
   521          kfree(ctx->maps);
   522          kfree(ctx->olaps);
   523          kfree(ctx);
   524  
   525          fastrpc_channel_ctx_put(cctx);
   526  }
   527  
   528  static void fastrpc_context_get(struct fastrpc_invoke_ctx *ctx)
   529  {
   530          kref_get(&ctx->refcount);
   531  }
   532  
   533  static void fastrpc_context_put(struct fastrpc_invoke_ctx *ctx)
   534  {
   535          kref_put(&ctx->refcount, fastrpc_context_free);
   536  }
   537  
   538  static void fastrpc_context_put_wq(struct work_struct *work)
   539  {
   540          struct fastrpc_invoke_ctx *ctx =
   541                          container_of(work, struct fastrpc_invoke_ctx, 
put_work);
   542  
   543          fastrpc_context_put(ctx);
   544  }
   545  
   546  #define CMP(aa, bb) ((aa) == (bb) ? 0 : (aa) < (bb) ? -1 : 1)
   547  static int olaps_cmp(const void *a, const void *b)
   548  {
   549          struct fastrpc_buf_overlap *pa = (struct fastrpc_buf_overlap 
*)a;
   550          struct fastrpc_buf_overlap *pb = (struct fastrpc_buf_overlap 
*)b;
   551          /* sort with lowest starting buffer first */
   552          int st = CMP(pa->start, pb->start);
   553          /* sort with highest ending buffer first */
   554          int ed = CMP(pb->end, pa->end);
   555  
   556          return st == 0 ? ed : st;
   557  }
   558  
   559  static void fastrpc_get_buff_overlaps(struct fastrpc_invoke_ctx *ctx)
   560  {
   561          u64 max_end = 0;
   562          int i;
   563  
   564          for (i = 0; i < ctx->nbufs; ++i) {
   565                  ctx->olaps[i].start = ctx->args[i].ptr;
   566                  ctx->olaps[i].end = ctx->olaps[i].start + 
ctx->args[i].length;
   567                  ctx->olaps[i].raix = i;
   568          }
   569  
   570          sort(ctx->olaps, ctx->nbufs, sizeof(*ctx->olaps), olaps_cmp, 
NULL);
   571  
   572          for (i = 0; i < ctx->nbufs; ++i) {
   573                  /* Falling inside previous range */
   574                  if (ctx->olaps[i].start < max_end) {
   575                          ctx->olaps[i].mstart = max_end;
   576                          ctx->olaps[i].mend = ctx->olaps[i].end;
   577                          ctx->olaps[i].offset = max_end - 
ctx->olaps[i].start;
   578  
   579                          if (ctx->olaps[i].end > max_end) {
   580                                  max_end = ctx->olaps[i].end;
   581                          } else {
   582                                  ctx->olaps[i].mend = 0;
   583                                  ctx->olaps[i].mstart = 0;
   584                          }
   585  
   586                  } else  {
   587                          ctx->olaps[i].mend = ctx->olaps[i].end;
   588                          ctx->olaps[i].mstart = ctx->olaps[i].start;
   589                          ctx->olaps[i].offset = 0;
   590                          max_end = ctx->olaps[i].end;
   591                  }
   592          }
   593  }
   594  
   595  static struct fastrpc_invoke_ctx *fastrpc_context_alloc(
   596                          struct fastrpc_user *user, u32 kernel, u32 sc,
   597                          struct fastrpc_invoke_args *args)
   598  {
   599          struct fastrpc_channel_ctx *cctx = user->cctx;
   600          struct fastrpc_invoke_ctx *ctx = NULL;
   601          unsigned long flags;
   602          int ret;
   603  
   604          ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
   605          if (!ctx)
   606                  return ERR_PTR(-ENOMEM);
   607  
   608          INIT_LIST_HEAD(&ctx->node);
   609          ctx->fl = user;
   610          ctx->nscalars = REMOTE_SCALARS_LENGTH(sc);
   611          ctx->nbufs = REMOTE_SCALARS_INBUFS(sc) +
   612                       REMOTE_SCALARS_OUTBUFS(sc);
   613  
   614          if (ctx->nscalars) {
   615                  ctx->maps = kcalloc(ctx->nscalars,
   616                                      sizeof(*ctx->maps), GFP_KERNEL);
   617                  if (!ctx->maps) {
   618                          kfree(ctx);
   619                          return ERR_PTR(-ENOMEM);
   620                  }
   621                  ctx->olaps = kcalloc(ctx->nscalars,
   622                                      sizeof(*ctx->olaps), GFP_KERNEL);
   623                  if (!ctx->olaps) {
   624                          kfree(ctx->maps);
   625                          kfree(ctx);
   626                          return ERR_PTR(-ENOMEM);
   627                  }
   628                  ctx->args = args;
   629                  fastrpc_get_buff_overlaps(ctx);
   630          }
   631  
   632          /* Released in fastrpc_context_put() */
   633          fastrpc_channel_ctx_get(cctx);
   634  
   635          ctx->sc = sc;
   636          ctx->retval = -1;
   637          ctx->pid = current->pid;
   638          ctx->client_id = user->client_id;
   639          ctx->cctx = cctx;
   640          init_completion(&ctx->work);
   641          INIT_WORK(&ctx->put_work, fastrpc_context_put_wq);
   642  
   643          spin_lock(&user->lock);
   644          list_add_tail(&ctx->node, &user->pending);
   645          spin_unlock(&user->lock);
   646  
   647          spin_lock_irqsave(&cctx->lock, flags);
   648          ret = idr_alloc_cyclic(&cctx->ctx_idr, ctx, 1,
   649                                 FASTRPC_CTX_MAX, GFP_ATOMIC);
   650          if (ret < 0) {
   651                  spin_unlock_irqrestore(&cctx->lock, flags);
   652                  goto err_idr;
   653          }
 > 654          ctx->ctxid = FIELD_PREP(FASTRPC_CTXID_MASK, ret);
   655          spin_unlock_irqrestore(&cctx->lock, flags);
   656  
   657          kref_init(&ctx->refcount);
   658  
   659          return ctx;
   660  err_idr:
   661          spin_lock(&user->lock);
   662          list_del(&ctx->node);
   663          spin_unlock(&user->lock);
   664          fastrpc_channel_ctx_put(cctx);
   665          kfree(ctx->maps);
   666          kfree(ctx->olaps);
   667          kfree(ctx);
   668  
   669          return ERR_PTR(ret);
   670  }
   671  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

Reply via email to