From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.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 3D63F31960A for ; Wed, 22 Jul 2026 00:15:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.199 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784679352; cv=none; b=UVNDfs6zdKgDy7gHpt8T4U6/PH6SLAAJX9tH5eXDyR5qE3B5KLRt7UZjNeZbvYrpvW1z39t7mOmX5hV7xrGX5PFepHXumCpdnbZjLdjAJ+kY49rZHR2tLDXtSQTGLLkdxX42LuR/H2FmQ8cYwGbzGgvbyx/vY1DbwnTBB5vJXow= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784679352; c=relaxed/simple; bh=lfTItr5Vg+lZepk1YTtimNxtQxX2xxsuhXX8/E8FyOA=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=kR0I248jS4MezXQnLwEkN2aOS9XCHeZwEEew20GnIuHEI0MXo+RXwHWyvPLmClTZ9GFwpHJbfPgpATK6eEvrIqrnrG06s8+NKgpSS1bp7m55QcE/6pwsdl8W0+kVUN37lcpiBtz+B5kDj5hMTNXkorUmhRaD8/ZPkkewira5aQU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jrhilke.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=hmBqsgrU; arc=none smtp.client-ip=209.85.215.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--jrhilke.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="hmBqsgrU" Received: by mail-pg1-f199.google.com with SMTP id 41be03b00d2f7-c860544c077so19990006a12.3 for ; Tue, 21 Jul 2026 17:15:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1784679347; x=1785284147; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=eZ+JYUl+bJF8E+CsVPDDHP5xTQJTCrW/WMk4UkvfNvM=; b=hmBqsgrUjnFUFOOyBjzxhfhOcRgrE6pvFKFhgW8D+E9YTV53QBstvn4DbBFWvU3vu3 ItNu32xBTfX3eD1qShImmIfeeZ25yI5eZYW9Yyqu5jnolrNKUKRBbcXJ0CHRp6oQvBUM l+u8WYf9GFHaCCZ1rWrpzrDKaSLCkyYwly1XebBvFserPsUFCBlMb8MYYMNdTUFH0y6s nIXS6ma1hDMsmxP24B4g64KhQMzk4BEAYzOhipqYE6xArr4tYuoU1fI42lQ6uap3Y7lF n2FIthZjsLqfcCvIfMwDaJQgCy3s6iShBth83WwJBeWsFpiUdyM4vHyz7cHtypMwBFrq eGIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784679347; x=1785284147; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=eZ+JYUl+bJF8E+CsVPDDHP5xTQJTCrW/WMk4UkvfNvM=; b=QJfhc0RBfaMyWt8zAvYsJYsM1A2TIIycZ68cbaquPphCK+AMXm/+A0UlZ4VR/Np0Tb 4tkg083gQC6OxokRuWTvzUN71MWKpdMbBp8FysY4d6jSxiy4kpzEuDYAURC34Bmjgn8m evf/F7KefXZi0zca2OpVRJmS2fm6ifqJcoybeOvhV9fWwK7KclsB7ZENNWfeEX4xTHk6 BZ+B2UmhiOlYwopO3qIrxidahEAZs5ozu858E6GJelzzxZxlBkYjcmOjHwtbgW1czs3P BCr+h/vikKRjwPZluWes6IH0WY39SE2Dx2dZZGquRrsOAD7xk3gBm3sL+6S+cgzCgw8u 1SHg== X-Forwarded-Encrypted: i=1; AHgh+RrYybihhGEOGYTqgUAd2Ilk/LIBLBZmdg/Wgeih4MYUkijqXvmraK2gUmN2zQPWLUomCqhH8EvKPAoyRe8=@vger.kernel.org X-Gm-Message-State: AOJu0Yz56R3Yjw8tCgpHdK2RbYnNzHXWvmd5iYICJyJkwFwB1cESFttY E2VQLOzh/CG35Bv71Nc+GcQ15NGww3J6aRN+dLjdIoG9ezGBy+xKkPSIXetUhNjNf4sgcRBes51 nMg8vOk8D X-Received: from pgww13-n1.prod.google.com ([2002:a05:6a02:2c8d:10b0:c8a:c79:47e7]) (user=jrhilke job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:c70b:b0:3c3:7427:5ed8 with SMTP id adf61e73a8af0-3c3ad5fc1cdmr23350917637.8.1784679346553; Tue, 21 Jul 2026 17:15:46 -0700 (PDT) Date: Wed, 22 Jul 2026 00:15:40 +0000 In-Reply-To: <20260722-igb_v3_b4-v6-0-0be1d29918d4@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260722-igb_v3_b4-v6-0-0be1d29918d4@google.com> X-Developer-Key: i=jrhilke@google.com; a=ed25519; pk=cK+Urrh214DoCHywJiTwhMP+zcs1ofpGrewToO/i/3A= X-Developer-Signature: v=1; a=ed25519-sha256; t=1784679337; l=2385; i=jrhilke@google.com; s=20260710; h=from:subject:message-id; bh=lfTItr5Vg+lZepk1YTtimNxtQxX2xxsuhXX8/E8FyOA=; b=FwaSkyLKFRNCDrxuhKdnvvYY8lP/k/mmM0g9bHg2OIqLQqw3ScD4PobkBcMqhKdOSAoROja30 F/ZYfWzQN6UA1YEKPiTvjn4KNqM8wBlII40LcWweQbDp5vIgwzQYMmB X-Mailer: b4 0.14.3 Message-ID: <20260722-igb_v3_b4-v6-5-0be1d29918d4@google.com> Subject: [PATCH v6 5/6] vfio: selftests: Retry on EAGAIN during device reset From: Josh Hilke To: David Matlack , Alex Williamson Cc: Shuah Khan , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, Vipin Sharma , Josh Hilke Content-Type: text/plain; charset="utf-8" Add retry logic to vfio_pci_device_reset() to handle the case where PCI resets fail due to lock contention, in which case pci_try_reset_function() returns -EAGAIN. Suggested-by: Sashiko Suggested-by: David Matlack Signed-off-by: Josh Hilke --- .../vfio/lib/include/libvfio/vfio_pci_device.h | 1 + tools/testing/selftests/vfio/lib/vfio_pci_device.c | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/vfio/lib/include/libvfio/vfio_pci_device.h b/tools/testing/selftests/vfio/lib/include/libvfio/vfio_pci_device.h index 2e67afc0d580..27bdf561925f 100644 --- a/tools/testing/selftests/vfio/lib/include/libvfio/vfio_pci_device.h +++ b/tools/testing/selftests/vfio/lib/include/libvfio/vfio_pci_device.h @@ -41,6 +41,7 @@ struct vfio_pci_device { struct vfio_pci_device *vfio_pci_device_init(const char *bdf, struct iommu *iommu); void vfio_pci_device_cleanup(struct vfio_pci_device *device); +int __vfio_pci_device_reset(struct vfio_pci_device *device); void vfio_pci_device_reset(struct vfio_pci_device *device); void vfio_pci_config_access(struct vfio_pci_device *device, bool write, diff --git a/tools/testing/selftests/vfio/lib/vfio_pci_device.c b/tools/testing/selftests/vfio/lib/vfio_pci_device.c index 7b8394d0ac50..1b29cef96b04 100644 --- a/tools/testing/selftests/vfio/lib/vfio_pci_device.c +++ b/tools/testing/selftests/vfio/lib/vfio_pci_device.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only #include +#include #include #include #include @@ -221,9 +222,23 @@ void vfio_pci_config_access(struct vfio_pci_device *device, bool write, write ? "write to" : "read from", config); } +int __vfio_pci_device_reset(struct vfio_pci_device *device) +{ + if (ioctl(device->fd, VFIO_DEVICE_RESET, NULL)) + return -errno; + + return 0; +} + void vfio_pci_device_reset(struct vfio_pci_device *device) { - ioctl_assert(device->fd, VFIO_DEVICE_RESET, NULL); + int r; + + do { + r = __vfio_pci_device_reset(device); + } while (r == -EAGAIN); + + VFIO_ASSERT_EQ(r, 0, "ioctl(device->fd, VFIO_DEVICE_RESET) failed\n"); } static unsigned int vfio_pci_get_group_from_dev(const char *bdf) -- 2.55.0.229.g6434b31f56-goog