From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) (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 C54D370836 for ; Wed, 5 Aug 2026 00:34:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.199 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785890053; cv=none; b=Nz7gfI8sfOKwE2Ax8BKRPId1zTtLSECFGJQ8ShgcpBHtT+5dnsJNPn0wtEEBvHam2IWBxLk/K75vroOSbTOUEvz72QC730RMZqnulGknsDcbFGHMvi79AEwzQPr6QA2+nlKUb0gMtiE+PLZ9BSuPtciwJdA/kJ7wXH1yHZmI9UQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785890053; c=relaxed/simple; bh=txfxTrmu+bo3oAJ8VLDmk/FEIiIVSSTxEa8Qi/4Y5OM=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=tVoeNJKiKQvNoK1XfkA3jZif8TaaUjlF+KZlWX/V1u4+DGH4KdDNhcJBag/7YklXE0GCI77Rk6ZhxCaDNOU30Os+733kjFcq3nbeVhoIYs/GtXekVLjXL5RfTWfe5pf0wO/sw4hxfau8SDe0cBOm1PU5DMPmxru8GFjblBk72RY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--skhawaja.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=i9tsLmln; arc=none smtp.client-ip=209.85.214.199 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--skhawaja.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="i9tsLmln" Received: by mail-pl1-f199.google.com with SMTP id d9443c01a7336-2cee1ec30f2so5169245ad.3 for ; Tue, 04 Aug 2026 17:34:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1785890051; x=1786494851; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:mime-version:date:from :to:cc:subject:date:message-id:reply-to:content-type; bh=9QIg9D06eO1oZhT/bjT3ycpnRcl5W9Zb/r8esri7h6U=; b=i9tsLmln3eeRAlV2jqyPng0vS9QG+/YRZX7khntGbwfqjiBpsA7g5sK0jX0mQJ9QHA 5l6aAfHszzubnmtf/ZQLs13qRIUHEU/hWxxEQtk4htQuMVHnOZ8MpFvoEWBuCgz2TvrZ T0XTzKMxolv8cMW4pC7o2ht4+ItxZC0i7miWptBXbA1CQqKebE/mt9nj8Sq7T8sbkfRZ R/p9JRcoCj/XkYF0o0ZSCEsA5vW86iTwcwxRQKSrhRtRuFiziNRZuwLs2Mwv2Eky47nX /p0UZ3QJmN0F6jDuwlEHCJtrgMBxG5v/S9y4VpsV6i7m42ZgWCZEvWpND/0Y0GJVugSt 4tZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785890051; x=1786494851; h=content-type:cc:to:from:subject:message-id:mime-version:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=9QIg9D06eO1oZhT/bjT3ycpnRcl5W9Zb/r8esri7h6U=; b=KUuniq+KieYKosNvXsoMsIv8SWQWNhw6rNP9ASEiywYaZ1+bQNq0I5WRSuKEqwaJnj 787BnW821uDIDSMjnsQz0vWXD9uV3mZq6OKPWRHCUL8fwfzZg2YnRQiTtbnpQ3KzNi5A OFGAYFVC7tmt2zIY1f5dibo0hWVADtuxcJCFIOp7SIq7vEZmLZyuPHOY1kU+g8BOF0YQ 8kU0PpYU8Ik7Jny8H0PYsqJrjfEdUd6hglDN318tZQA5FPaWJNnc8fWduvgXuIA2muFc YZWkeFsBaRD3lxdNa+oEC+quMPSbqeFV+gw6Xy8BA4EPmdH2sQe67YGkfvbVsfFlGUv3 bkqA== X-Forwarded-Encrypted: i=1; AHgh+RqCJySbV/vQ4eYV9wjPgEeRvgbUVx8h3KI/TCOXf5F4KSwEwr5AcmXHioaW2m39Lw1wbXzo5qwIkN4RLvM=@vger.kernel.org X-Gm-Message-State: AOJu0YwcIMDIxafD592FHckb0Kw6GwzP8XIObz2ZrLcbxa+NtlUakN8T E+BNjSVl/PvnrRoiG8RHDgi6HLHhHVuM2sXHRQprSlOXMzLWEhVp37nWoPZ7EyajWGDBAJ/Y1sv /v7ZBISXk70sNAQ== X-Received: from plcm11.prod.google.com ([2002:a17:902:f20b:b0:2cf:ee73:1d9d]) (user=skhawaja job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:1aed:b0:2cc:8267:31b5 with SMTP id d9443c01a7336-2d0caa03976mr32512675ad.19.1785890050806; Tue, 04 Aug 2026 17:34:10 -0700 (PDT) Date: Wed, 5 Aug 2026 00:33:54 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.55.0.629.g250fe7f194-goog Message-ID: <20260805003355.728299-1-skhawaja@google.com> Subject: [RFC PATCH 0/1] vfio/pci: Disable sriov on PF device close From: Samiullah Khawaja To: Alex Williamson , Jason Gunthorpe , bhelgaas@google.com Cc: Samiullah Khawaja , dmatlack@google.com, Kevin Tian , Leon Romanovsky , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" When userspace closes a VFIO device file descriptor, the vfio driver performs a hardware reset on the PCIe device to ensure it is returned to a clean state. However, if the closed device is an SR-IOV Physical Function (PF), it may have instantiated Virtual Functions (VFs) that are actively bound to host kernel drivers (or other vfio instances). When the PF is hardware-reset via VFIO, it implicitly disrupts SR-IOV operations at the device level. Because this reset happens without notifying the core PCI driver model, the kernel drivers bound to the VFs remain loaded and operate under the assumption that the VF hardware is still functional. This creates a state mismatch between the kernel's view of the hardware and the actual device state. Subsequent attempts by the host OS or bound drivers to interact with the VFs will fail, leading to unexpected errors. Disabling SRIOV before resetting the device avoids this issue by tearing down the VFs and removing the VF devices. The fix in this patch only disables SRIOV on PF reset for devices bound to vfio-pci drivers. But this probably needs a fix for kernel drivers also, maybe return -EBUSY when SRIOV is enabled? Looking forward to your feedback on this. --- CC: bhelgaas@google.com CC: dmatlack@google.com Samiullah Khawaja (1): vfio/pci: Disable sriov on PF device close drivers/vfio/pci/vfio_pci_core.c | 7 +++++++ 1 file changed, 7 insertions(+) base-commit: 0f6da28aab51b16762ed82e8fdeaa5042da45b08 -- 2.55.0.629.g250fe7f194-goog