From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dy1-f174.google.com (mail-dy1-f174.google.com [74.125.82.174]) (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 5806D334681 for ; Fri, 10 Apr 2026 22:49:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775861398; cv=none; b=o0B/Vy6WJa25+hNXEXdhll4S0OkxkAXsjVJp6K6jGYY4iKBPeCfcoeo85QGpsdAtpB7jno6+g92QNTo4TeyxqsOrQsHVE0IG6HdlAHZzoqedqSpdNxK+w595SlB0D7RlkgI6UWhgCMSlMAMw1GT21jJdBYksAI7/M6L7//tzoJU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775861398; c=relaxed/simple; bh=64G/HZlnttl1hOl+ny+PHRUSlzFks9sd2njYjb4o00g=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=TsSvwKYZXOnVSy8OsC2t/4I5FVCbCxSsnHBfLbchsQ69OtLjz94ykXGEJf096Hm4pG5GanSt4lIOYvwvlGtW6CWUm7FoLVAwyoaAO5nJFgNkHCRguKcxClAn8GYcPMSXtCgxLaAikH437akD/FhG5pzLmRYI1YxcJhTNq0y0TOM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=NQ5bKyJ1; arc=none smtp.client-ip=74.125.82.174 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=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="NQ5bKyJ1" Received: by mail-dy1-f174.google.com with SMTP id 5a478bee46e88-2c7d8bbad06so4308075eec.1 for ; Fri, 10 Apr 2026 15:49:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1775861395; x=1776466195; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=ohdxTjV33OOUB3WjGB+FykFCNcpu8iYa4Zz1gdjkPto=; b=NQ5bKyJ19L9qtArNdisSbsLPqq8/sNrJpbnGREMKDveFDK3dI02wMu0xw3chFL59fj 8efX7wwAEjtlq8OMhpm9/RBvPiQ0ZYuSfy5WcN6VoVG13kPM5PG1C7PGvqwOFUH2Ao52 yD1e6NPDChp9TVIT4U53cmGMAJfXryvy8KUo20iZf9ieEqFxpcNLYL4ZPrzH2UsDnoAr rP3RLjn/g3Zn7IorkNubVfuwUsKbsc0AaevNJj/NvnThVbE/668bygWn9P4ow47dV4/7 /ui6gAZvWypBEd4qqrP9VwQddtLgIJo6kyPjlJySnLyA4UDCHzbQ6fk438m9KdcRGmxJ Wblg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775861395; x=1776466195; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ohdxTjV33OOUB3WjGB+FykFCNcpu8iYa4Zz1gdjkPto=; b=dEPHq79t0QHLWwndBN+C4tuO7WswdsbdrqgAcdW+GeIPXue1mzT3aeMp4zEhUAbegX BzB3JyR+CbKyAKJFdfdlLZK4HJYz7upWDvA8MES0wr5bMHCMU7C/SqmnHy4OXTr1Q+KP /3Njsm8qNGHFCJn5tb09FX1MpKi/H8/LflPu+bOVMUylncxLax1987RggfBay1hLnQWr s4BTVrAdQOVLHCPXhmZqgx4EWzjqbidFmBNscFhRxkrRiKNDCrOYNuzLz9a2F2IV6Gzh fWa7hOeBSbpjFcEBHufQUZkJYQ6QbYr+W49NkBbekEF8Z/cd1x9sWSQm2tKJaSv2cHqX Xi3Q== X-Forwarded-Encrypted: i=1; AJvYcCVfDdXjb6Fu8Y1gXPC3nDlS08S2IXNEqZ33AHibkeBFqKPR4pTz2CATW7UdVNTQZgACqtTvUA1cxOR+zTE=@vger.kernel.org X-Gm-Message-State: AOJu0Yw2I4RtBylAZs/QiphTiB60AfPCDjp5p/IsZEP1NA7/kyyqMhzy AVvqRg1s/3AOKL7gYPqLUOKTcUhXOejDdJwXnzOvPasVCwtHsc0RwmqfIZwJveqP1g== X-Gm-Gg: AeBDieupGBtLOdswZPrswK9PSL1oNEw1aHoAiC5wYG2PZEtvSZvVpbIYM/QslaKenp8 Z+X9+pnBiWaVvhJzTEIJLR95vrtB2B4BnDNaTG5uAMLDp1ogbY8mO1ALxf/Uj+blUHaYonV/LUv nwjrm/RzNNUHDAdep7YN4V6twYGqKGSFvFKIoQpcK+WNj45jg8yp5hVLyGVEB/E7gKeK5uMnKxk 5BgihgxjEXYGfXC7/fCSIDbWzMmLpTnEEXAbPzWINhL7qzThTcABkpLOeDyjOrV5JGzItrxL56W XnanuZqSOaehbFVGfi4sotlGywQeTGfWuN+y8SH9iQrEuGtKMPkbyNo0WvYBKiMoXKXaqKYNt4I F/QkPvyavdJ/2ebTWC4HI+TnSXNmiZL49o4JNO1EsPWgIOW7XjE1or1/5zjd81by9hHPzUSVV5B z6/QCPjP30dWU2DrZckjiviKJJPEnAN6dsvzxWEN6zLIvKl1jqAFkO87VKJ9GZJStbfZU= X-Received: by 2002:a05:7301:1f10:b0:2d3:2983:c895 with SMTP id 5a478bee46e88-2d5879944aamr3271952eec.7.1775861394995; Fri, 10 Apr 2026 15:49:54 -0700 (PDT) Received: from google.com (76.9.127.34.bc.googleusercontent.com. [34.127.9.76]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2d561bde717sm6329546eec.19.2026.04.10.15.49.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Apr 2026 15:49:54 -0700 (PDT) Date: Fri, 10 Apr 2026 22:49:49 +0000 From: David Matlack To: Josh Hilke Cc: Alex Williamson , Vipin Sharma , Raghavendra Rao Ananta , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, seanjc@google.com Subject: Re: [PATCH 2/2] vfio: selftests: Automate setting up devices for testing Message-ID: References: <20260409015139.2800185-1-jrhilke@google.com> <20260409015139.2800185-3-jrhilke@google.com> 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-Disposition: inline In-Reply-To: <20260409015139.2800185-3-jrhilke@google.com> On 2026-04-09 01:51 AM, Josh Hilke wrote: > Update the VFIO selftest setup script to find a device that has a VFIO selftest > driver on the system, and set it up (i.e unbind that device from its driver, and > then bind that device to VFIO). > > This makes the process of setting up a device to VFIO selftests much easier, as > users don't have to manually figure out which device to use. Though, users can > still manually setup a device by passing the -d argument with a > segment:bus:device.function number. > > Example of automated device setup: > > $ ./tools/testing/selftests/vfio/scripts/setup.sh./setup.sh Script path here got garbled > + echo "0000:6a:01.0" > /sys/bus/pci/drivers/idxd/unbind > + echo "vfio-pci" > /sys/bus/pci/devices/0000:6a:01.0/driver_override > + echo "0000:6a:01.0" > /sys/bus/pci/drivers/vfio-pci/bind > Successfully set up 0000:6a:01.0 > > Example of automated device setup where no compatible devices exist: > > $ . ./tools/testing/selftests/vfio/scripts/setup.sh/setup.sh Here too, also the extra '.' before the path looks like a mistake. > No available supported devices found on the system. > > Example of manual device setup: > > $ ./tools/testing/selftests/vfio/scripts/setup.sh -d 0000:6a:01.0 > + echo "0000:6a:01.0" > /sys/bus/pci/drivers/idxd/unbind > + echo "vfio-pci" > /sys/bus/pci/devices/0000:6a:01.0/driver_override > + echo "0000:6a:01.0" > /sys/bus/pci/drivers/vfio-pci/bind > Successfully set up 0000:6a:01.0 > > Signed-off-by: Josh Hilke Please add Suggested-by tag for Sean and also Cc Sean on next version of the series :) > --- > tools/testing/selftests/vfio/scripts/setup.sh | 22 +++++++++++++++++-- > 1 file changed, 20 insertions(+), 2 deletions(-) > > diff --git a/tools/testing/selftests/vfio/scripts/setup.sh b/tools/testing/selftests/vfio/scripts/setup.sh > index 2cde07eb9c8b..6d4492b211ea 100755 > --- a/tools/testing/selftests/vfio/scripts/setup.sh > +++ b/tools/testing/selftests/vfio/scripts/setup.sh > @@ -19,11 +19,30 @@ function print_supported_devices() { > done > } > > +function pick_device() { > + local bdf > + > + while read -r bdf; do > + if [ -n "${bdf}" ]; then > + if [ -d "${DEVICES_DIR}/${bdf}" ]; then > + echo "${bdf} has already been set up, exiting." >&2 > + exit 0 > + fi > + echo "${bdf}" > + return 0 > + fi > + done <<< "$(print_supported_devices)" > + > + echo "No available supported devices found on the system." >&2 I think we should make it clear what "supported" means in this log. This is about finding a device that has a VFIO selftests driver, which is only required by some tests. Same goes for the -l option in the previous commit actually and the usage message below. > + exit 1 > +} > + > function usage() { > echo "usage: $0 [-l] [-d ]" >&2 > echo "" >&2 > echo " -l List segment:bus:device.function numbers of supported devices." >&2 > echo " -d segment:bus:device.function to set up." >&2 > + echo " If -d is not specified, a device will be automatically picked." >&2 > } > > function main() { > @@ -46,8 +65,7 @@ function main() { > done > > if [ ${#bdf_list[@]} -eq 0 ]; then > - usage > - exit 1 > + bdf_list=($(pick_device)) Sashiko thinks this will ignore any errors from pick_device(): https://sashiko.dev/#/patchset/20260409015139.2800185-1-jrhilke%40google.com?part=2 > fi > > for device_bdf in "${bdf_list[@]}"; do > -- > 2.53.0.1213.gd9a14994de-goog >