Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp755594lqg; Sat, 2 Mar 2024 00:04:01 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW4qaH2AkcPy6dMI+bTraAvbHBEYh3SSG4dWwX6AmcBKwmzp/7mleGsSWPR/NHuvId3mFc6dPOfE1jcYqKsDgDk/lwjaokL4VbTXZGEHQ== X-Google-Smtp-Source: AGHT+IGGAHsJ4qf1ZEc6CORmiizK3HzOqz9jSPZRWxJuE2rhOka+GOoXSQAzvws1ikgfsFepmrmX X-Received: by 2002:a05:6402:b03:b0:565:6951:9aaa with SMTP id bm3-20020a0564020b0300b0056569519aaamr3266006edb.21.1709366641466; Sat, 02 Mar 2024 00:04:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709366641; cv=pass; d=google.com; s=arc-20160816; b=iJ5R2o6bRAHb2kJCHNf2G5B6+rcCr4rkUWWq63Cyk5f2zhuJjc8zHbJwFopu96rLsz gl61xObO0/MryG6P0wgP+ugSPq5UMhDby9e/pPymEeHvN9rPXX+vFFAhDwFXxNERXPv1 nc7X8+2JtfLcqcSqa9f2sj88RNqxKu2/lPAk0XczDC0ZY59e+tbYPtNlww/bWWOII3IZ WdYsymPljXEwYpcJPXtt3o7pEY7amOEl2U+cLxriY72/Gav9ZhEg+2ZXE7ck8fckHYir mRqVQb8kyHCMgVYiE5BwxzAvX7HG5sMCq2If1wgA0JvlVn2duIvZgpZ9uzUpKoCNKGHI +wqg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=zTtwyLuMQZYDIdScIDkWo0slksDe2lL20o949vHYP3M=; fh=mApT7LlA5OHSQUIsVX9piGOrZelHhUfFzJ1Yu3516Eg=; b=zr1y2u4g1mVjC3ZUzKsamj+JMm0oumaHLKoekp0J5L5X0ZtNI9o1q5OPVQ3C8HYKiu myEShAe/ZCtcMwkf30SJOMlM8oj2gWHlzzE5hadKoxKy9vMATv/ZfvJ3jMwAq7vxdOXP pObriu3Ko4ZqByHSPQK3tf2juy72P8CNZfKFq563CURvtgOojUxuo6NbySzKB+TgyYbk 8N4YuHWeNfk8DxkLn9f9ua5OYXX0VmZvYDZ8z9ujnZxQLePZL81xOjdzFWVCl6llWluZ AM9ddUnSe7e6vnpOrOMh1TlkRcGHM9uKvmc1g6yvsGjqjRT40G+4/jIiZ2g9MLPfOgSN Yqxw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ar6BLWrf; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-89363-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89363-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id x10-20020a50d60a000000b00565beaaaba0si216137edi.672.2024.03.02.00.04.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Mar 2024 00:04:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89363-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ar6BLWrf; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-89363-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89363-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 2C2871F22DC7 for ; Sat, 2 Mar 2024 08:04:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2735212E42; Sat, 2 Mar 2024 08:03:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Ar6BLWrf" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 37CDF11C82; Sat, 2 Mar 2024 08:03:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709366632; cv=none; b=ZjVMCVmVjHEiVVZF1GOrk+g4FYoaBn8Kv/kr3nOLWtONa0QskbP4cV5nKG6YdZ5bUTj6VQXqSLazX7dzmUAvcDupE4CkofwLsECjHKr8NK1UtG36BLNO9eH+343M8RRqFhk6I9/9sXU/Qp8XA6k3yufRdtIoJe+LAHy071sJnDU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709366632; c=relaxed/simple; bh=iLkoAAFp9B+Iiazgd42bfbnBTX49YWjdJO2wLKJivbQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=giuaeobuBwZ1LmeMsjNvB4JukrDzgqJ+raTdavjATvZFvMN60zNxHzJgU186xV91tecdkYGLKYnPcqWdVmaP2TT3N/i+Mb92lnVPLEsU/aASqULHK8Y6shqONgX7fEqcrUgrR2uZ2AP9XAKHU/bv+I11mnqExaG3N8OGNeL24nY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Ar6BLWrf; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6BA68C433F1; Sat, 2 Mar 2024 08:03:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709366631; bh=iLkoAAFp9B+Iiazgd42bfbnBTX49YWjdJO2wLKJivbQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Ar6BLWrfx01/2OynHfhCsdnHlK2Ew2UYQQu/PYWV9edoumn1NCcH0l81eYVcGqDL1 cnYR5OKILRLmuUtQnDLuOqOSkISMlLiE4KJRQkMSBFPnukTF9Lw+2YmvNX/Jbq3PAJ qXWqCqXaVwF0yv9F4EXOahoYo8HxSScSoPSf38rRDiPD09oIZK0Dm/tTSnuL4TQajW Y+8CO+kThPe7PN+Pfdt1JeRvQcIytf2kGOzdtpqacH2pRXUd47fnQHJbHMnZAJTy2A riSp+PVmpjBxg3hkrmntxm1XdAO8Qj2cQjUxSvMnxk4e9WBdBlHacHGvw9eA/xcw23 yHHgMsm4V2aVg== Date: Sat, 2 Mar 2024 00:03:49 -0800 From: Saeed Mahameed To: Vegard Nossum Cc: Arnd Bergmann , Greg Kroah-Hartman , linux-api@vger.kernel.org, Linux Documentation , Leon Romanovsky , Jason Gunthorpe , Jiri Pirko , Leonid Bloch , Itay Avraham , Jakub Kicinski , Saeed Mahameed , David Ahern , Aron Silverton , Christoph Hellwig , andrew.gospodarek@broadcom.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH V4 3/5] misc: mlx5ctl: Add info ioctl Message-ID: References: <20240207072435.14182-1-saeed@kernel.org> <20240207072435.14182-4-saeed@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: On 29 Feb 12:47, Vegard Nossum wrote: > >On 07/02/2024 08:24, Saeed Mahameed wrote: >>+static int mlx5ctl_info_ioctl(struct file *file, >>+ struct mlx5ctl_info __user *arg, >>+ size_t usize) >>+{ >>+ struct mlx5ctl_fd *mfd = file->private_data; >>+ size_t ksize = sizeof(struct mlx5ctl_info); >>+ struct mlx5ctl_dev *mcdev = mfd->mcdev; >>+ struct mlx5_core_dev *mdev = mcdev->mdev; >>+ struct mlx5ctl_info *info; >>+ int err = 0; >>+ >>+ if (usize < ksize) >>+ return -EINVAL; >>+ >>+ info = kzalloc(ksize, GFP_KERNEL); >>+ if (!info) >>+ return -ENOMEM; > >struct mlx5ctl_info is small, why not put it on the stack or even copy >it directly from the original object, assuming it has no holes/padding? > There's no original object, but yes storing it on the stack should work. >>+ >>+ info->dev_uctx_cap = MLX5_CAP_GEN(mdev, uctx_cap); >>+ info->uctx_cap = mfd->uctx_cap; >>+ info->uctx_uid = mfd->uctx_uid; >>+ info->ucap = mfd->ucap; >>+ >>+ if (copy_to_user(arg, info, ksize)) >>+ err = -EFAULT; >>+ >>+ kfree(info); >>+ return err; >>+} > >Is there even a remote possibility of extending this structure in the >future? If so the size check will not allow you to be backwards >compatible. Should there be a version field in there or would you >just add a new ioctl altogether? Adding linux-api@vger.kernel.org to Cc. > This was my original implementation, but Greg's preference is to allow no extension to the ioctl structures, in case of extension required, new IOCTL and structure should be introduced. >>diff --git a/include/uapi/misc/mlx5ctl.h b/include/uapi/misc/mlx5ctl.h >>new file mode 100644 >>index 000000000000..9be944128025 >>--- /dev/null >>+++ b/include/uapi/misc/mlx5ctl.h >>@@ -0,0 +1,20 @@ >>+/* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 WITH Linux-syscall-note */ >>+/* Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. */ >>+ >>+#ifndef __MLX5CTL_IOCTL_H__ >>+#define __MLX5CTL_IOCTL_H__ >>+ >>+struct mlx5ctl_info { >>+ __u16 uctx_uid; /* current process allocated UCTX UID */ >>+ __u16 reserved1; /* explicit padding must be zero */ >>+ __u32 uctx_cap; /* current process effective UCTX cap */ >>+ __u32 dev_uctx_cap; /* device's UCTX capabilities */ >>+ __u32 ucap; /* process user capability */ >>+}; >>+ >>+#define MLX5CTL_IOCTL_MAGIC 0x5c >>+ >>+#define MLX5CTL_IOCTL_INFO \ >>+ _IOR(MLX5CTL_IOCTL_MAGIC, 0x0, struct mlx5ctl_info) >>+ >>+#endif /* __MLX5CTL_IOCTL_H__ */ > >Should you add anything to Documentation/ABI/ ? (Or add other >documentation for this driver?) > The driver doesn't expose any sysfs other than the IOCTLs, but yes a documentation might be useful to make sure ABI is stable, most of the other drivers point out to the uapi header for documentation.