From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (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 E30681F4C96 for ; Wed, 24 Jun 2026 13:39:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782308382; cv=none; b=MC3u37EaY7UPVEUOULfrNO+CXAWhCmU+htIHBMtyyQ+xv093W45s87ObyFYJbHn3H0rAzy2DE/jTKpWjj6hb7BlBMW+wRbzSi++NvB2rSLhJ/7H4QXpWGNJp9UZ3qOkZUU6YeDY0zaE/eyyrGN5xO2nLQVZ5NECBweAWVAwkwOQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782308382; c=relaxed/simple; bh=bCN9QXSeKcThALlWIblZF+dwzG/gKPOqYW26oOCeuYE=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=XHiLH5FwJa8XwUfCZxc3mL2/vkYoLyA8SgwFTqsEDE+te9hqfPbnB18FriFOUa+9pKFxW6Tbt5j+YMBtNpnviC0DzXoN/uUs/JN58OpITS9uh0kQbvnCC3q+eTX2WI07/QuhdX+3pl3jokShUCMyqiNAqNCwiFapQbT0qOyRK/M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=KcyCZtx9; arc=none smtp.client-ip=209.85.128.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KcyCZtx9" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-4924f8db066so6182705e9.2 for ; Wed, 24 Jun 2026 06:39:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782308379; x=1782913179; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=uwEU/3SC+a/Dow+usckYBKgjXhWK/UqDUFsUC31pETA=; b=KcyCZtx9qxuc+0yrIq+Aq6pi4uXTW0VkpB4rqjAr2vYAizL1QqtBAt4DR52MJfNwNh //vtlmwxxhWJf4iUXLFYW8LsHWEfaeDfD4yvH26cJ0+1x7A0L9S/koaoR/YxHHzz/sOr 2s+Wx/cT4ANNrFjFuvCmOs9XQyL+NYojGhcAFlKXX/N4kHhsQFeAuzHjWEVC+U8Qmpu3 XkE4l29vjfkUiygFN+Wul1zZeCBsEQcgmwVmVI7YqvcvbgEL2cp3yV0hVb1GLIBDUAGa d+UZjbUR9leSGQtX7NFwbtyOnszRZoN5Dxl4bRF12+vaCEkcTup8e4kPGs3XE/PkExT6 hRhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782308379; x=1782913179; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=uwEU/3SC+a/Dow+usckYBKgjXhWK/UqDUFsUC31pETA=; b=B17O86Ak6HgBCD0B2N+gX5Y/hRgCBX3USGsMZ+D3/IEQWyK+sX81rfaCl0GDCyJw66 e4krygBXIx7VMEZx65J2AFCLQyljibVAFGBZSA6bW6CAec+am/sRg7Ru98USxxUdV02u kPzfmKglRU6GvCOwYu2fuea2P2bzPUVbWYHB2+eEUEyIlYeAE5K57hSymj0PEuAnouPt 9IK15Bj8YaMtP17vNmjK1MTQPWBiccfjxPkYo6c77rnEZRaqLi6mSvT5mTwsTLalabga 0qWLccg1/4e/GEu8S8edstE5VJ8jCDa8FaPmelwg5qhaZTmC9Lxhcr6sqSAeeJk0kT+a iXzw== X-Forwarded-Encrypted: i=1; AFNElJ81/myDaYS7bwkMqm9kV1AqZKh986mbvkwvYflFSzNSIaawKK9SLwp1XpGWq2JDooXjvUV0zXqaPSV3ZkA=@vger.kernel.org X-Gm-Message-State: AOJu0YwBj3noLPyeFPZ6SKfjjNWf3B0vrPD9EJZyoH4mZPTjjTZ2PVXd Hf78oUtjX0jozz+XacoOArSub5CHDcYHCwlZEbfH3YU/B7Cp4J8fUepm X-Gm-Gg: AfdE7cmtA2dfxQxl9tiCdFVtOAhHBYFIU5gJ9kH+gfkovfOJQwi4MQGiypQiv7JorxO NLx/RHH8J06ghJLQH9XVJwBnlu2cIfZDkzbtmeYGi7Pk343N/phjWRa2A0HqUWyx8HeyvS+SS2j Gq+AQlf9UyZTbEMKdKDLs5zTXt+GaQMi8pI3FLhdmmJRbpv9LEB08mMMs5g+w1V3AQR/4Q4ouX+ A4b7XhXN1GkMow6dfoLq8kCkM4a2/FY4PscPGThMQkQsIOI/NZQZP52Ui7XW3xGfLf8RP3LtFZu CqypBK1iGh52GZfiBrDmtxJ1mvHN3Rj+VrraioL5QF2ezwyOyMOX5iZiIqJVD5CRVXUk9IhgaVC GEI711Eo/nApV/wTvTFwfakPfWGk1maRo+SPEo3TJ4dJwy2WEBpD0Nv5Pnnj7shnobM4Q35OBg1 ojyvzvKXnrt1bqt49Qzu94QHsFwdJFOdpKECLBT/hW1BPHhIwlpfOSAM1MKMpv X-Received: by 2002:a05:600c:8b77:b0:492:4911:8a with SMTP id 5b1f17b1804b1-4925b35a0f9mr107690435e9.12.1782308379175; Wed, 24 Jun 2026 06:39:39 -0700 (PDT) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4923fc47720sm802880225e9.0.2026.06.24.06.39.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jun 2026 06:39:38 -0700 (PDT) Date: Wed, 24 Jun 2026 14:39:37 +0100 From: David Laight To: "Alexandre Courbot" Cc: "Zhi Wang" , , , , , , , , , , , , , , , , , , , , , , , , , , , , "Bjorn Helgaas" , Subject: Re: [PATCH v2 1/7] PCI/IOV: Return u16 from pci_sriov_get_totalvfs() Message-ID: <20260624143937.50499c29@pumpkin> In-Reply-To: References: <20260622194353.1308872-1-zhiw@nvidia.com> <20260622194353.1308872-2-zhiw@nvidia.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) 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 Content-Transfer-Encoding: 7bit On Wed, 24 Jun 2026 21:40:52 +0900 "Alexandre Courbot" wrote: > On Tue Jun 23, 2026 at 4:43 AM JST, Zhi Wang wrote: > > pci_sriov_get_totalvfs() reports a VF count, not an errno-style > > status. It returns 0 when SR-IOV is unavailable or the device is not a > > PF, and otherwise returns the PF's driver_max_VFs value. > > > > driver_max_VFs is stored as a u16 in struct pci_sriov. It is derived > > from the SR-IOV TotalVFs field or from a driver-provided limit, so the > > implementation cannot return a negative value. > > > > Change the declaration, CONFIG_PCI_IOV stub, and implementation to > > return u16. Update callers to store the result in u16 variables, remove > > obsolete negative-value checks, and use unsigned format specifiers where > > needed. > > > > Cc: Bjorn Helgaas > > Cc: linux-pci@vger.kernel.org > > Signed-off-by: Zhi Wang > > Suggested-by: Alexandre Courbot > Link: https://lore.kernel.org/all/DETDILPA1GFY.27WND0TEC5352@nvidia.com/ > > > --- > > drivers/crypto/hisilicon/qm.c | 8 +++++--- > > drivers/crypto/intel/qat/qat_common/adf_sriov.c | 6 +++--- > > drivers/gpu/drm/xe/xe_sriov_pf.c | 6 ++---- > > drivers/misc/genwqe/card_base.c | 6 ++---- > > drivers/net/ethernet/cavium/thunder/nic_main.c | 2 +- > > drivers/net/ethernet/emulex/benet/be_main.c | 3 ++- > > drivers/net/ethernet/mellanox/mlx5/core/sriov.c | 3 ++- > > drivers/net/ethernet/sfc/ef10_sriov.c | 2 +- > > I believe that you can avoid converting all these drivers in this patch. > The implicit `u16 -> int` conversion done by C should result in the > expected behavior, and it will be fewer Acked-by to collect. The generated code is also likely to be slightly better if the function return value is a 32bit value. Similarly you don't really want to do any kind of maths on local variables that aren't 32bit (or 64bit on 64bit builds). The fact that the domain of a value fits in 16 bits doesn't mean that it is better to use u16 - it is usually worse. Pretty much the only place u16 should be used is to reduce the size of structures. So it is probably correct to change the return type to unsigned int and remove the error return checks, but nothing else. David > > I.e. just updating drivers/pci/iov.c and include/linux/pci.h should be > sufficient as the first step. Specific drivers can then be updated using > separate patches that will be easier to merge individually, if you want > to do so. >