From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qv1-f97.google.com (mail-qv1-f97.google.com [209.85.219.97]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7F93B3128D9 for ; Sat, 23 May 2026 17:24:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.97 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779557049; cv=none; b=elVRyfdLXsAshmdFKOf3oXj2kV9cPurg94Pp29RjbcQjxy9M8BjY0M+mtdQD+odBEL+a/UBiRCdAWc96X3JwlkncUI9S7h58GkTAGl8V/QmpGSoIpOUWZE+duL15bTOWNBYpzF3dBrttJK6FDA3N5SIJtHHoMldyr40kcjF6DTY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779557049; c=relaxed/simple; bh=+oGL8o2f+/VpYDT5bWsT9/G3XCeTueTDbeclHvv+ipA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kjryiPB0Mak6GAfa0nbF1kSTf8G3wWanrfDLdlVps1evF1VkEyfGSDyKEq1HhTiVj8ZQvjhlcpY55SglYtjx9vXmZuqMHFBSkr/vIUfdYYg396VZhxuMo9p/ikdp1rMBEIONpddIrxCb9qGbxekzQtsIPfk0L4Jr1Q8TeIoYKdo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=J+3rBJDs; arc=none smtp.client-ip=209.85.219.97 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="J+3rBJDs" Received: by mail-qv1-f97.google.com with SMTP id 6a1803df08f44-8acae26e564so107480146d6.2 for ; Sat, 23 May 2026 10:24:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779557046; x=1780161846; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=QyodfGiK/5h16DoRFvLdnrOIJL4tpwtgD7ZUYlspi6I=; b=dzRrSJNC+Tl+Cli+gHWilXjutGIkb2lww/oN57WpdRsnCBENJjHelfg+mWbY3rSl3Q gNRDExzXgoqbSAwWhaVLZIRM+k+py6Vx2Wigpre2gf5tsYWBMFb/8Mhngob8ezOLTCgV PXQLDwDXsNDBZo+H/0YHKW2iNIKDUbVurOjzL283T730l5xPlB0Qmyi2AzgY0xjljhVL ZrK9VZuL8QRixPIIlBjtX6IcDlRn/ly9JykcHxBGQwRyttTXdfOeBz0UkUU8OjYua/iR XWysT7DgjeHNvCV9PmEZLN4KRLD4RHiFeOc+WGxh/OR0mwIBmAcbjRHrU9nCNDAJxZ3x 2jVA== X-Gm-Message-State: AOJu0YykbQHauDzUqhtf/ICMti1XzVg5yMJkmF5kKlBweUNHxLn8A7aC uXifG63j3hNAIKbQkgnpF/1r5q/SbpCxyayP9DCrhK3njVI3Jr2FKfcsJsiGK5efoYpigFnAKky VPAELE43TQNMSRrkwt809X2WCc4RxHlQNATKVH3TshDkiIaKsIrcMsgAYNumUw7pw24WWFCJoUm xB+SICtBSZ6z+QqbsTvO8umQaujHXBaX4Y53h4zk0Ww/PE0sY0nMNTMaE51vwCBSF59zPOK6mGA dk21rf7zrM866+b2Hw= X-Gm-Gg: Acq92OHb4HWj0Dss5JFJDKJxErymcZynXu0N6WRsMMgQJ0P85xhU72HnnlZSPaRlQp+ xvngQ+flj/qwG9iDoqagPvzGyiqog9v5lCyFkp7ah3GRqe+WwO9QJ1n/r/sod2mV1PrUdOBjhvF 3RoFqmrAqaO1LLnD/QnK3e/0t+hTGri4g+6q/SEG8R39aJ+1JLAqhcSL8DSTQWzRiUNt446Jl0i F7qPvfvGYNW5lJqH8Xc2oukS+EFk1imPVNeXv6BvAnL7GqPKE+b1u+rqq0e4zJsDJ4ppGqm0v/v eDUvHVU+Ni6Rj+bWpZJwW8Inrd7bYaoN35Jhuh7MbKNGvS6oIKJxyXNWN8nKbHe30ek3kDLXwoe NED/UkMbNz8mk95w0Y3muK8PgfbmsKqMTu0h4/Deq9X4ysGw8AHcN8qbaM5PixzpzOYiOcuM6Wv 2LsSQw/agMbklbSjeefERR4dAxtmpUsccdLqTpCu43alx7+4nmBv6jm2CWU6o= X-Received: by 2002:a05:6214:3c87:b0:8cc:d29:9f79 with SMTP id 6a1803df08f44-8cc7b604e76mr143177446d6.4.1779557046430; Sat, 23 May 2026 10:24:06 -0700 (PDT) Received: from smtp-us-east1-p01-i01-si01.dlp.protect.broadcom.com (address-144-49-247-117.dlp.protect.broadcom.com. [144.49.247.117]) by smtp-relay.gmail.com with ESMTPS id 6a1803df08f44-8cc81302822sm2948956d6.18.2026.05.23.10.24.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 23 May 2026 10:24:06 -0700 (PDT) X-Relaying-Domain: broadcom.com X-CFilter-Loop: Reflected Received: by mail-pj1-f69.google.com with SMTP id 98e67ed59e1d1-366344513a3so17266698a91.3 for ; Sat, 23 May 2026 10:24:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1779557045; x=1780161845; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=QyodfGiK/5h16DoRFvLdnrOIJL4tpwtgD7ZUYlspi6I=; b=J+3rBJDsPqBxRLHwz0VeEc8FJf+zi6BiYI8dJJxJvcACqCApalRxag/4ip3VBlShU5 UFPQXZG/c7JM2z0V/oux0IzlQMXwUx/b6R42x9DGGIHSAWuTpmQRyx55FmyDNBlx3nys 1RB8+F90OZPrw+LW2kj5I9wuUcL1slYRFU0CQ= X-Received: by 2002:a17:90b:1d8c:b0:366:33a6:9921 with SMTP id 98e67ed59e1d1-36a67422decmr7820536a91.4.1779557044953; Sat, 23 May 2026 10:24:04 -0700 (PDT) X-Received: by 2002:a17:90b:1d8c:b0:366:33a6:9921 with SMTP id 98e67ed59e1d1-36a67422decmr7820525a91.4.1779557044513; Sat, 23 May 2026 10:24:04 -0700 (PDT) Received: from pc-hpe-top-git-sendmail-server.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-36a725d0109sm6839847a91.17.2026.05.23.10.23.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 May 2026 10:24:01 -0700 (PDT) From: Pavan Chebbi To: jgg@ziepe.ca, michael.chan@broadcom.com Cc: linux-kernel@vger.kernel.org, dave.jiang@intel.com, saeedm@nvidia.com, jic23@kernel.org, gospo@broadcom.com, selvin.xavier@broadcom.com, leon@kernel.org, kalesh-anakkur.purayil@broadcom.com, Pavan Chebbi Subject: [PATCH v2 fwctl 1/3] fwctl: Add driver_data field to fwctl_rpc Date: Sat, 23 May 2026 22:55:18 +0530 Message-ID: <20260523172520.627531-2-pavan.chebbi@broadcom.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260523172520.627531-1-pavan.chebbi@broadcom.com> References: <20260523172520.627531-1-pavan.chebbi@broadcom.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-DetectorID-Processed: b00c1d49-9d2e-4205-b15f-d015386d3d5e 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 --- 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) -- 2.52.0