From mboxrd@z Thu Jan 1 00:00:00 1970 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 ECBB5279354; Thu, 2 Oct 2025 18:43:05 +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=1759430586; cv=none; b=MrH4OBM8b9IxS6fs3hpUdvdpUgjOb1ygmX2lrDOnN9csMFkzfGuXVIJtRMTus9vq9bWnUzvIlCcOrs3cJ6qrwkQ10/QDwUi5VoOBzxhOfBexZeEw43hpQaVAD26fQRQ1kctXmoSmxi68dfMJ9DRblr36yvLa92Dy4Q9/16+lr+8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759430586; c=relaxed/simple; bh=QBNmt5nQdlSHz9BzuBtd1eA2i421wdZw4slxcTsU9mI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=tQaofDYOLs9ZZs3HrkPyEWQV0g0SD/2y6yQLFZBqluHYd0a3KZYiFdREXLCm4k2EZl55v/EpyinnBOJEGz1UsZLmMXuiZjQCQj7BJzjzT9uKfioB+jAIbWOUMIaRmUhDeJY5AJEZ8M6oJg8WdUsHlmhZw/A+0gIkrm5/TQa28zk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZZxiVwJQ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZZxiVwJQ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A9A5BC4CEF4; Thu, 2 Oct 2025 18:43:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1759430585; bh=QBNmt5nQdlSHz9BzuBtd1eA2i421wdZw4slxcTsU9mI=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=ZZxiVwJQ3Gdddbl8tlI81HLrcH+SF1gBXj73zyK1t/LCdnFStHGm2vLioyscg8PWL rxGjFhzTnlkA5myQXJMtParIPOuheo+6qYqwVPYkWsIjOcgtkoEYsRORCvggv1agiK mzItaIqY/mlrzFmBB/PC3SGNGW6IZjECH29l070K29qRC16WcnNE88NTJGlR493y6S pZLYKk1tchd103m2436bNFmX1y4cE5QCeIgBjTBWCFVnxeUe+xwEFxoIjYqzGmuEwN Bo4K/61gEWrtqNQ3w54P4A6H83COawIobBmOF4gXr8S2r6RVne6x5Yt5lJ9gdHJHVK jQ7AUhjza0BVA== Message-ID: <56daf2fe-5554-4d52-94b3-feec4834c5be@kernel.org> Date: Thu, 2 Oct 2025 20:42:58 +0200 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 v2 1/2] rust: pci: skip probing VFs if driver doesn't support VFs To: Jason Gunthorpe Cc: John Hubbard , Alexandre Courbot , Joel Fernandes , Timur Tabi , Alistair Popple , Zhi Wang , Surath Mitra , David Airlie , Simona Vetter , Alex Williamson , Bjorn Helgaas , =?UTF-8?Q?Krzysztof_Wilczy=C5=84ski?= , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?UTF-8?Q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , nouveau@lists.freedesktop.org, linux-pci@vger.kernel.org, rust-for-linux@vger.kernel.org, LKML References: <20251002135600.GB3266220@nvidia.com> <20251002152346.GA3298749@nvidia.com> <20251002170506.GA3299207@nvidia.com> <20251002180525.GC3299207@nvidia.com> <3ab338fb-3336-4294-bd21-abd26bc18392@kernel.org> <20251002183114.GD3299207@nvidia.com> From: Danilo Krummrich Content-Language: en-US In-Reply-To: <20251002183114.GD3299207@nvidia.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 10/2/25 8:31 PM, Jason Gunthorpe wrote: > This exactly how this function is used. > > The core PF driver provides an API: > > struct mlx5_core_dev *mlx5_vf_get_core_dev(struct pci_dev *pdev) > > Which takes in the VF as pdev and internally it invokes: > > mdev = pci_iov_get_pf_drvdata(pdev, &mlx5_core_driver); Oh, I see, that makes sense then. Thanks for clarifying. I think I already had in mind how this would look like in the Rust abstraction, and there we don't need pci_iov_get_pf_drvdata() to achieve the same thing. > /** > * pci_iov_get_pf_drvdata - Return the drvdata of a PF > * @dev: VF pci_dev > * @pf_driver: Device driver required to own the PF > * > * This must be called from a context that ensures that a VF driver is attached. > * The value returned is invalid once the VF driver completes its remove() > * callback. > * > * Locking is achieved by the driver core. A VF driver cannot be probed until > * pci_enable_sriov() is called and pci_disable_sriov() does not return until > * all VF drivers have completed their remove(). > * > * The PF driver must call pci_disable_sriov() before it begins to destroy the > * drvdata. > */ > > Meaning nova-core has to guarentee to call pci_disable_sriov() before > remove completes or before a failing probe returns as part of > implementing SRIOV support. Yes, I already thought about this. In the context of adding support for SR-IOV in the Rust abstractions I'm planning on sending an RFC to let the subsystem provide this guarantee instead (at least under certain conditions). This will allow us to assert the device to be bound by the type system in the Rust PCI abstraction, rather than having the driver to provide a guarantee to call pci_disable_sriov() manually. :)