From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dy1-f171.google.com (mail-dy1-f171.google.com [74.125.82.171]) (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 5D9C53E0C5A for ; Fri, 10 Apr 2026 22:40:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775860846; cv=none; b=e5azEtexGPvZFIz/Hr6Wkaq+dSnXn7SS6PPY6Hq/KFRs8ZCYM71Cl76EPoY8tEuJnGOlh/4jlJ7W1kMniMh8/MVBLxXn7RvIPlEtYtRP9GQK01noSGiwo7LIPiHek34n/hNrQYpw1Uww3jnZ/e3iCfSTQybBNteL/Qab+0wWM8o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775860846; c=relaxed/simple; bh=tzOUR/LjuCfGJr/mVgqXlCaulTU4vWiEidNGpq4dce0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=txOKJ+KTlB4hgf17XRvi8W8Wo/25NyYhbbPIej1AhoREHgN9uZw/f+o3VIran6lOt4/fwh2zHv/kqW2UYBGrv4JDKQ8pxKi7kVqr5/1YBvVCm1QBJ8w9gG+ywCa1taEYTDUhfdBzpB9xluK6r2fO7NvhNhO2rnmuVvayjY5vli0= 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=fdlL5Ev7; arc=none smtp.client-ip=74.125.82.171 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="fdlL5Ev7" Received: by mail-dy1-f171.google.com with SMTP id 5a478bee46e88-2d323567f11so1141624eec.1 for ; Fri, 10 Apr 2026 15:40:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1775860844; x=1776465644; 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=8slB+3H8dMazOpqXNIOvI2WoIOKP4mrqv8umSrDoEpw=; b=fdlL5Ev7i81anTLA6eZa20w8wwt/JCbMjoPAZ3/1pTwE9vL4VV72IF7ZqMKTK6mmqA 3ElnzZXjV/BBpkuoIEkyGqAo7ATqX2q4ut9C7+AJFufewWQJrlvWd1CtBF/RHducb9aa 4qNw4WrOS8nRhkkKiT7XFwMISwITVxG+5Fgd6ORCb5O34fhb5ZYEIxNCuVeVGm5rqC4R 3Tp3Psg4uQEq0t53pUUxul9zSBPCGRqlQaJt31NXxTl9KbhRJwcOwKNLV7rEW0zfaSDe WwM3FTaJU+42RB+Tk7PtF+ENC874GWi1BzVE97S5f/GKQGiGiu3Psr4xt4CCHRCUpzEq 96iQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775860844; x=1776465644; 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=8slB+3H8dMazOpqXNIOvI2WoIOKP4mrqv8umSrDoEpw=; b=EmQwwhzocQe3GOu226vsv8zYpOVLOh0Wy9XIqvrNN5R+a7YyNTYcvP7lQGS8K8tELK c43kOH4lB7LkOGhgO+xdquIytIxRGk8fpPNRmlyFy7I/dAcuxJeu0uZqboK781Cb+hOu miXaSDLn3DVUWKF6lhrwpjL7OMGgZQOejnxdjByzgyZqPXk0ousBUHl/Bwa9lLrFRG+7 6Riu3JqZS/OxD3bl5t+86D8/hoEJltF3ychcMKN+4dCGpVYpytwt8dJN22Osljw6TKlp ox1zrlmya+QDiW3hq2QUtNgdy92WjXm/61NyIolzDnOKNwxcfgr8I3b2SFc5AZKUOvqM KXnA== X-Forwarded-Encrypted: i=1; AJvYcCVCnHxUawn+add0C3QdDoUn1pEMvUlNmpZsqspVzOx316ezH0otv5y8qieaXcPmCDuecPscNZEr1iQXHRM=@vger.kernel.org X-Gm-Message-State: AOJu0Yw/QJ7cmZ8B27oaXvdjFRP3RJiNpPyIlPVMYYcP+bWMsY/UdkdW GfJmsemR7NKWLi5s+i/4Ayie33GbdAyzrW6UY2fKrgE9K3cHYAVEFdj3NMZY5s5Faw== X-Gm-Gg: AeBDievPIJRTR110acKCPP68LLQ4AgHdzlnp2kRUMskm5Vsg0KQbjiKd1gm/a4RWreJ HhZiWeaW4OT8lPTXyZXYYeyuuWZXq1IsJ05N8WT9KEdK3OTrKXAFvAt6UYPE8gYt5YGkxsQ6oRb cfeWmrXoTurgSqxWblACsjOa7SC5VWilRKqyG3E4wG0/FgrVxCNbA/DeZ7MzelueWLxO7wOJVLg PZWzH/E9XV5nrFnmhiaBLst8V8eaCf7Rv4tyei6QvG9RdfdaEaYHPlWhWwzM7FuXWon8CmpE7u8 juHnEUgSZ3YyM333ZxrfjAztX2OEMRPpT0D17n7vio5uy+NJhEJSeyxKFywB5rFsaOFpreoCc2X PZA7ZUYiTRfJ1jkd2weaPzl9vJMvL3WSz0/uO1/buFXKLhTPsEzaZhL3kRvOQKeauq2u5/JFvRn A689PftkauKdq8TEORCOS/WYVrG49wyK/8GyNGxSDJ72FRuXzF3kSgBpwHsHOnRTqVS1tASlw/q QqCAg== X-Received: by 2002:a05:7300:a90b:b0:2c7:6218:9830 with SMTP id 5a478bee46e88-2d59b5b3b34mr2205147eec.11.1775860843901; Fri, 10 Apr 2026 15:40:43 -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-2d55f5c69b3sm6302440eec.1.2026.04.10.15.40.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Apr 2026 15:40:42 -0700 (PDT) Date: Fri, 10 Apr 2026 22:40:38 +0000 From: David Matlack To: Josh Hilke Cc: Alex Williamson , Vipin Sharma , Raghavendra Rao Ananta , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] vfio: selftests: Find devices that are compatible with VFIO selftests Message-ID: References: <20260409015139.2800185-1-jrhilke@google.com> <20260409015139.2800185-2-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-2-jrhilke@google.com> On 2026-04-09 01:51 AM, Josh Hilke wrote: > Update the VFIO selftest setup script to print the segment:bus:device.function > numbers of devices on the user's system that have VFIO selftest drivers (i.e. > are compatible with the VFIO selftest infrastructure). This makes it easy for > users to quickly find devices that are compatible with VFIO selftests. > > Example of how to list compatible devices on the system: > > $ ./tools/testing/selftests/vfio/scripts/setup.sh -l > Supported devices: > 0000:6a:01.0 > 0000:6f:01.0 > 0000:74:01.0 > 0000:79:01.0 > 0000:e7:01.0 > 0000:ec:01.0 > 0000:f1:01.0 > 0000:f6:01.0 > > Example of setting up a device: > > $ ./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 > > This makes the script much more user friendly so that no one has to dig > around in the VFIO selftest libraries to figure out which devices can > run the selftests. > > Signed-off-by: Josh Hilke > --- > tools/testing/selftests/vfio/scripts/setup.sh | 43 +++++++++++++++++-- > 1 file changed, 40 insertions(+), 3 deletions(-) > > diff --git a/tools/testing/selftests/vfio/scripts/setup.sh b/tools/testing/selftests/vfio/scripts/setup.sh > index 49a499e51cbe..2cde07eb9c8b 100755 > --- a/tools/testing/selftests/vfio/scripts/setup.sh > +++ b/tools/testing/selftests/vfio/scripts/setup.sh > @@ -3,18 +3,54 @@ set -e > > source $(dirname -- "${BASH_SOURCE[0]}")/lib.sh > > +# List of devices which have a VFIO selftest driver > +DEVICES=( > + "8086:0b25" # Intel Data Streaming Accelerator Please also add the new DMR and GNR-D DSA devices that were added recently: https://github.com/awilliam/linux-vfio/commit/c82cfe15916d33e89c2d2efeeb624e8c9c2c4ca8 > + "8086:0cf8" # Intel CBDMA > +) > + > +function print_supported_devices() { > + local vendor_device_id > + local id > + > + for vendor_device_id in "${DEVICES[@]}"; do > + read -r id <<< "${vendor_device_id}" Sashiko seems to think the read here is unecessary. https://sashiko.dev/#/patchset/20260409015139.2800185-1-jrhilke%40google.com?part=1 > + lspci -D -d "${id}" | awk '{ print $1 }' Let's print the whole line and let the user parse out the BDF with awk. That will let the user see which type of device it its rather than just raw BDFs. > + done > +} > + > +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 > +} > + > function main() { > local device_bdf > local device_dir > local numvfs > local driver > + local bdf_list=() > + > + while getopts "ld:" opt; do > + case ${opt} in > + l) > + echo "Supported devices: " > + print_supported_devices > + exit 0 > + ;; nit: Put the echo in print_supported_devices and this can be a one-liner like the rest of the options. while getopts "ld:" opt; do case ${opt} in l) print_supported_devices; exit 0 ;; d) bdf_list+=("${OPTARG}") ;; *) usage; exit 1 ;; esac done > + d) bdf_list+=("${OPTARG}") ;; Let's keep the current semantics where the list of BDFs is passed as positional arguments. The next commit would just pick a device if there are no positional arguments. This will keep the script backwards compatible with current usage and also keep it simple (no need to pass extra -d flag for every BDF): ./setup.sh BDF1 BDF2 BDF3 vs. ./setup.sh -d BDF1 -d BDF2 -d BDF3 > + *) usage; exit 1 ;; > + esac > + done > > - if [ $# = 0 ]; then > - echo "usage: $0 segment:bus:device.function ..." >&2 > + if [ ${#bdf_list[@]} -eq 0 ]; then > + usage > exit 1 > fi > > - for device_bdf in "$@"; do > + for device_bdf in "${bdf_list[@]}"; do > test -d /sys/bus/pci/devices/${device_bdf} > > device_dir=${DEVICES_DIR}/${device_bdf} > @@ -42,6 +78,7 @@ function main() { > > bind ${device_bdf} vfio-pci > touch ${device_dir}/vfio-pci > + echo "Successfully set up ${device_bdf}" > done > } > > -- > 2.53.0.1213.gd9a14994de-goog >