From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (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 BC46318B0F for ; Tue, 26 May 2026 20:46:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779828368; cv=none; b=RuJhLu2EIuJ7TmC9t5pouaTOMQYxgD7FlD6CXbz9hJAc4JCInicDnj9DFOD84/kQ9l0jtAe9yDFPIZMWs9JmyQfdpYtlI8J4jzK90yGVR9dhgRSDkOT9r+YJy7pGaycw98T5I3pSpGR8n7XEfkp9VpcJ1fom3GJDqeHiEWeNm+U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779828368; c=relaxed/simple; bh=HCPln1mzMKkbx6Cee4L7UvOCUHE1EUj/nBx8G9zEPXU=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=UGyT1zk13+hhXmM7xSZZURyyRkZQrTRIJszWeEpY7aJgp8zyF3BVWDtBDrIU+dw6JHuQe5n6b8NMlOKVLjH6A59Lyqc6tSrmC6eHYYSQQrXR5zdcp8k7w5tTj3SDucHfz1B5CH/HXK9UrOwD3V4M64/GHBi9IYbfxmDlYbQF5eg= 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=RkOImOSw; arc=none smtp.client-ip=192.198.163.11 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="RkOImOSw" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1779828367; x=1811364367; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=HCPln1mzMKkbx6Cee4L7UvOCUHE1EUj/nBx8G9zEPXU=; b=RkOImOSwfxOpsM1TVE5mm6wqi/n6rvf+BnbEeErMyv2mQck8anZs4X99 tvy2sGMFUc8L88lzj53SWXm+XDnkOOiETw81lCGWJCiBqlhcSYMHuUeDE LrSydG8YBczM0SXEqL3YgYLR2yfAxHchd0SKmEZfm84iwlSfuN6BlE0of 5SZrRBFEshXkk2ZTygq6UBAp9SQhO3h2yrCl3utf1mwrNW4g1/S0q/z7s q/cyQEzxvnhvXt7+nUGazuoh95yUSDs36XaiTX4XNferrMfibRzZ8CIli DK3mZVfWKGkeUnCqMaKUw1gyJVzF8lcRP27OkRjvKgO6pTdbOWhWN8sC6 A==; X-CSE-ConnectionGUID: W0yutGxrQWWYGxJaYDn8zA== X-CSE-MsgGUID: zkREStprSf2abrQSQWKD4A== X-IronPort-AV: E=McAfee;i="6800,10657,11798"; a="91225404" X-IronPort-AV: E=Sophos;i="6.24,170,1774335600"; d="scan'208";a="91225404" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 May 2026 13:46:06 -0700 X-CSE-ConnectionGUID: 0zpmjnTiSuibPbbKNRVzCQ== X-CSE-MsgGUID: vuBgyIXJRBG+EerZefvMqA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.24,170,1774335600"; d="scan'208";a="243853971" Received: from aduenasd-mobl5.amr.corp.intel.com (HELO [10.125.110.201]) ([10.125.110.201]) by fmviesa004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 May 2026 13:46:05 -0700 Message-ID: Date: Tue, 26 May 2026 13:46:03 -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 v3 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, jic23@kernel.org, gospo@broadcom.com, selvin.xavier@broadcom.com, leon@kernel.org, kalesh-anakkur.purayil@broadcom.com References: <20260526144507.822095-1-pavan.chebbi@broadcom.com> <20260526144507.822095-2-pavan.chebbi@broadcom.com> Content-Language: en-US From: Dave Jiang In-Reply-To: <20260526144507.822095-2-pavan.chebbi@broadcom.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 5/26/26 7:45 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 drivers' fw_rpc implementations to enforce this. > > Signed-off-by: Pavan Chebbi Reviewed-by: Dave Jiang > --- > drivers/cxl/core/features.c | 6 +++++- > drivers/fwctl/bnxt/main.c | 6 +++++- > 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 +++ > 7 files changed, 31 insertions(+), 7 deletions(-) > > diff --git a/drivers/cxl/core/features.c b/drivers/cxl/core/features.c > index 3435db9ea6b1..a0d7f26c5b6d 100644 > --- a/drivers/cxl/core/features.c > +++ b/drivers/cxl/core/features.c > @@ -643,7 +643,8 @@ static void *cxlctl_handle_commands(struct cxl_features_state *cxlfs, > } > > static void *cxlctl_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 fwctl_device *fwctl_dev = uctx->fwctl; > struct cxl_memdev *cxlmd = fwctl_to_memdev(fwctl_dev); > @@ -651,6 +652,9 @@ static void *cxlctl_fw_rpc(struct fwctl_uctx *uctx, enum fwctl_rpc_scope scope, > const struct fwctl_rpc_cxl *rpc_in = in; > u16 opcode = rpc_in->opcode; > > + if (driver_data) > + return ERR_PTR(-EOPNOTSUPP); > + > if (!cxlctl_validate_hw_command(cxlfs, rpc_in, scope, opcode)) > return ERR_PTR(-EINVAL); > > diff --git a/drivers/fwctl/bnxt/main.c b/drivers/fwctl/bnxt/main.c > index 951c8ac2e0a1..5eb3651a1784 100644 > --- a/drivers/fwctl/bnxt/main.c > +++ b/drivers/fwctl/bnxt/main.c > @@ -172,7 +172,8 @@ static unsigned int bnxtctl_get_timeout(struct input *req) > > static void *bnxtctl_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 bnxtctl_dev *bnxtctl = > container_of(uctx->fwctl, struct bnxtctl_dev, fwctl); > @@ -180,6 +181,9 @@ static void *bnxtctl_fw_rpc(struct fwctl_uctx *uctx, > struct bnxt_fw_msg rpc_in = {0}; > int rc; > > + if (driver_data) > + return ERR_PTR(-EOPNOTSUPP); > + > if (in_len < sizeof(struct input) || in_len > HWRM_MAX_REQ_LEN) > return ERR_PTR(-EINVAL); > > 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) >