From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 53BEF37CD57 for ; Fri, 22 May 2026 16:02:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779465722; cv=none; b=JJdP3cL36oNqGoP4d5QyjsvKTq3k9GyeT1BDM7VfWgG2cU1DWdGrXuMkS5bGRNHQfglDA2xMNdPwcNpopfsm/1MDCPrTDGqSTZ3sOjKmAVd1+uMj6pM/zuPrcZD7Tx7C47PFUD0FXxvUp11QEpxATcXMidrG6QiTtSGvGiFLvmg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779465722; c=relaxed/simple; bh=Wl2pydAZU5Tan+trzu3JI3NST5l9BTuu4SO4dx7zFoE=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=QSdvRAmvtikjZjSX13nx54JUq2dxmM8HJQx2RE4ZBaHQej/2EVoAVgiOxC4rHZgonsH7JE4+st0K4/AggCN8iamspqIo6RRdpxIa8S6bXK2C0fMtoXwbE9vpPw2iu5I48kG6Qtq9EfWsfZSEcI5YstSH/6V8YSToEzUqR8SnENQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=LBVzBGCi; arc=none smtp.client-ip=192.198.163.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="LBVzBGCi" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1779465720; x=1811001720; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=Wl2pydAZU5Tan+trzu3JI3NST5l9BTuu4SO4dx7zFoE=; b=LBVzBGCivHPTGbFjDiVGPpN2Nd/UgFrykTF7sepEN5EP9A6vJHGKUs8j nBeiAOna6vWAg4OARV4SHy/sGm2ldEGlTbWaHZ2l0l7Upnfn2QdThr3H9 SDFFe1GZWu1pXkd97e31YZ2q1NJMILi5urcOV1jn98JmTiaqd3/2fh1IN pb5EtgfV9bX2DsRdeXjYFuEMl5AjFORHfYs21yyLrYXawykMl3qsFUR6G EbjpzWO3M+c4IqPCTzAs9LnlbfgPOTzTEe+wOHZroVIrlMebZ8Y+0SyB1 nRm9MQ1r34epq/u0Avud8ODYg3bWA6QJgBFUB5N6C7cqvS8hxEEbbqf+d A==; X-CSE-ConnectionGUID: GXUHQUFDQWKvdZ6PKMseaA== X-CSE-MsgGUID: PLbOqBgHSG61QPAedLax1Q== X-IronPort-AV: E=McAfee;i="6800,10657,11794"; a="79547214" X-IronPort-AV: E=Sophos;i="6.24,162,1774335600"; d="scan'208";a="79547214" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 May 2026 09:01:59 -0700 X-CSE-ConnectionGUID: O0auW7S9RNWQMQX6+D5irQ== X-CSE-MsgGUID: XtNuG0qHTrOV084SLEt83Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.24,162,1774335600"; d="scan'208";a="234592794" Received: from schen9-mobl4.amr.corp.intel.com (HELO [10.125.110.86]) ([10.125.110.86]) by fmviesa009-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 May 2026 09:01:58 -0700 Message-ID: <4f2d5dc4-a85d-45e0-8947-f51f0e6b2524@intel.com> Date: Fri, 22 May 2026 09:01:57 -0700 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH fwctl 1/3] fwctl: Add driver_data field to fwctl_rpc To: Pavan Chebbi , jgg@ziepe.ca, michael.chan@broadcom.com Cc: linux-kernel@vger.kernel.org, saeedm@nvidia.com, Jonathan.Cameron@huawei.com, gospo@broadcom.com, selvin.xavier@broadcom.com, leon@kernel.org, kalesh-anakkur.purayil@broadcom.com References: <20260522080830.162740-1-pavan.chebbi@broadcom.com> <20260522080830.162740-2-pavan.chebbi@broadcom.com> Content-Language: en-US From: Dave Jiang In-Reply-To: <20260522080830.162740-2-pavan.chebbi@broadcom.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 5/22/26 1:08 AM, Pavan Chebbi wrote: > Add a driver_data field to struct fwctl_rpc in the UAPI and thread the > value through the fw_rpc() ops callback as a new __u64 parameter. The > field is opaque and driver-defined. > > Drivers that do not define a driver_data format may return -EOPNOTSUPP. > Update the existing mlx5 and pds fw_rpc implementations to enforce this. Can you also update drivers/cxl/core/features.c:cxlctl_fw_rpc() please? DJ > > Signed-off-by: Pavan Chebbi > --- > drivers/fwctl/main.c | 3 ++- > drivers/fwctl/mlx5/main.c | 6 +++++- > drivers/fwctl/pds/main.c | 6 +++++- > include/linux/fwctl.h | 8 ++++++-- > include/uapi/fwctl/fwctl.h | 3 +++ > 5 files changed, 21 insertions(+), 5 deletions(-) > > diff --git a/drivers/fwctl/main.c b/drivers/fwctl/main.c > index 098c3824ad75..32c4c66dd7d5 100644 > --- a/drivers/fwctl/main.c > +++ b/drivers/fwctl/main.c > @@ -122,7 +122,8 @@ static int fwctl_cmd_rpc(struct fwctl_ucmd *ucmd) > > out_len = cmd->out_len; > void *outbuf __free(kvfree) = fwctl->ops->fw_rpc( > - ucmd->uctx, cmd->scope, inbuf, cmd->in_len, &out_len); > + ucmd->uctx, cmd->scope, inbuf, cmd->in_len, &out_len, > + cmd->driver_data); > if (IS_ERR(outbuf)) > return PTR_ERR(outbuf); > if (outbuf == inbuf) { > diff --git a/drivers/fwctl/mlx5/main.c b/drivers/fwctl/mlx5/main.c > index e86ab703c767..2a5105769126 100644 > --- a/drivers/fwctl/mlx5/main.c > +++ b/drivers/fwctl/mlx5/main.c > @@ -304,7 +304,8 @@ static bool mlx5ctl_validate_rpc(const void *in, enum fwctl_rpc_scope scope) > } > > static void *mlx5ctl_fw_rpc(struct fwctl_uctx *uctx, enum fwctl_rpc_scope scope, > - void *rpc_in, size_t in_len, size_t *out_len) > + void *rpc_in, size_t in_len, size_t *out_len, > + __u64 driver_data) > { > struct mlx5ctl_dev *mcdev = > container_of(uctx->fwctl, struct mlx5ctl_dev, fwctl); > @@ -313,6 +314,9 @@ static void *mlx5ctl_fw_rpc(struct fwctl_uctx *uctx, enum fwctl_rpc_scope scope, > void *rpc_out; > int ret; > > + if (driver_data) > + return ERR_PTR(-EOPNOTSUPP); > + > if (in_len < MLX5_ST_SZ_BYTES(mbox_in_hdr) || > *out_len < MLX5_ST_SZ_BYTES(mbox_out_hdr)) > return ERR_PTR(-EMSGSIZE); > diff --git a/drivers/fwctl/pds/main.c b/drivers/fwctl/pds/main.c > index 08872ee8422f..bb61e60843cf 100644 > --- a/drivers/fwctl/pds/main.c > +++ b/drivers/fwctl/pds/main.c > @@ -348,7 +348,8 @@ static int pdsfc_validate_rpc(struct pdsfc_dev *pdsfc, > } > > static void *pdsfc_fw_rpc(struct fwctl_uctx *uctx, enum fwctl_rpc_scope scope, > - void *in, size_t in_len, size_t *out_len) > + void *in, size_t in_len, size_t *out_len, > + __u64 driver_data) > { > struct pdsfc_dev *pdsfc = container_of(uctx->fwctl, struct pdsfc_dev, fwctl); > struct device *dev = &uctx->fwctl->dev; > @@ -362,6 +363,9 @@ static void *pdsfc_fw_rpc(struct fwctl_uctx *uctx, enum fwctl_rpc_scope scope, > void *out = NULL; > int err; > > + if (driver_data) > + return ERR_PTR(-EOPNOTSUPP); > + > err = pdsfc_validate_rpc(pdsfc, rpc, scope); > if (err) > return ERR_PTR(err); > diff --git a/include/linux/fwctl.h b/include/linux/fwctl.h > index 5d61fc8a6871..afb7f72d0cb1 100644 > --- a/include/linux/fwctl.h > +++ b/include/linux/fwctl.h > @@ -51,10 +51,14 @@ struct fwctl_ops { > * @fw_rpc: Implement FWCTL_RPC. Deliver rpc_in/in_len to the FW and > * return the response and set out_len. rpc_in can be returned as the > * response pointer. Otherwise the returned pointer is freed with > - * kvfree(). > + * kvfree(). driver_data is the opaque value from fwctl_rpc, passed > + * verbatim from userspace. The driver is responsible for interpreting > + * and validating it. Drivers that do not define a driver_data format > + * must return -EOPNOTSUPP if driver_data is non-zero. > */ > void *(*fw_rpc)(struct fwctl_uctx *uctx, enum fwctl_rpc_scope scope, > - void *rpc_in, size_t in_len, size_t *out_len); > + void *rpc_in, size_t in_len, size_t *out_len, > + __u64 driver_data); > }; > > /** > diff --git a/include/uapi/fwctl/fwctl.h b/include/uapi/fwctl/fwctl.h > index 2d6d4049c205..2e07425402a3 100644 > --- a/include/uapi/fwctl/fwctl.h > +++ b/include/uapi/fwctl/fwctl.h > @@ -120,6 +120,8 @@ enum fwctl_rpc_scope { > * @out_len: Length of the out memory > * @in: Request message in device specific format > * @out: Response message in device specific format > + * @driver_data: Opaque userspace pointer passed verbatim to the driver. > + * Must be 0 for drivers that do not define a driver_data format. > * > * Deliver a Remote Procedure Call to the device FW and return the response. The > * call's parameters and return are marshaled into linear buffers of memory. Any > @@ -136,6 +138,7 @@ struct fwctl_rpc { > __u32 out_len; > __aligned_u64 in; > __aligned_u64 out; > + __aligned_u64 driver_data; > }; > #define FWCTL_RPC _IO(FWCTL_TYPE, FWCTL_CMD_RPC) >