From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 ED95A19342B for ; Fri, 3 Jan 2025 17:44:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735926276; cv=none; b=QXk4W5UnWcVVYp6ke3xbawMcndTy4VhzKPLK20WcufIF5fXXVPXwnBcWx0/joEcFkPB2ZJ1OG42bz3jyH/GI+VgDaEez4aP/QCkNYavJDRQ9JFCsHbtuM/QYba2jn0ch5/n19Fc8yrY8hZXugGD2K9OB6AFFpP87RsTqxGObJPk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735926276; c=relaxed/simple; bh=AAgcV5tMz9BZdUs8hahSn8mwaUiZZq1ZZhygCHYZ6CY=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=mccJrP/WLz4w3V0QYrIHCggT+ss72+bZ7jlP9k5lcoRr5dHOeR/LfdjsMz3eBXWneUodLkMQJxkqFhVzXPyOW8bal0qajKMwX1cll7P9sLbAByGsbSzVBybugMpWb9E6HycgolMZ94nZJ0Y6wpjBWZiVy39eJ8YWhBzpPoIo5ZU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=DedKMqRj; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="DedKMqRj" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1735926271; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=stVorBa8A94z2zV/9XfcMpSZKaiKlGhrH0FQVM2KGjE=; b=DedKMqRjdd2eBHCt7VVzVQRKmC03wDc+S908c8AyEDWRJaDjGsYhF3vvv2aOZiSNrBnKRU dIRBiDhnm931yGKItUT8wZHjP1g4kpVNNXnXfLN+qEbbFfDDrqyKPsN+ZVFIbJeQHrkQJ2 ijIHofpufOEOZ4Mq1BzwoS6X23EYJ2s= Received: from mail-io1-f72.google.com (mail-io1-f72.google.com [209.85.166.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-439-GFddQGCYPtus8izlRoN5Gg-1; Fri, 03 Jan 2025 12:44:30 -0500 X-MC-Unique: GFddQGCYPtus8izlRoN5Gg-1 X-Mimecast-MFC-AGG-ID: GFddQGCYPtus8izlRoN5Gg Received: by mail-io1-f72.google.com with SMTP id ca18e2360f4ac-844ebc11477so20883539f.3 for ; Fri, 03 Jan 2025 09:44:30 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735926270; x=1736531070; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=stVorBa8A94z2zV/9XfcMpSZKaiKlGhrH0FQVM2KGjE=; b=UfFpIqlplYe5yQWfNxeOiEpEdGGDYfmuZ4AlM3ElqnJ8pJF/CcgS1yD8tvzzkOxthV VCaMcrOONlQQ95Jk/UiM6lFmbNg0qwsX1DB1sgW4wbdm6bZl8+fBMgP6nMs6O6NKoo1t VDFwEd0birBPt9KECWsl9u/x8qxdpAFwFxbzOW/bwaaGqOArLRdAH5tsHhAGkz9rBceM UjjqF/MwcGDXR+QD4hSyhnqI1xnBtFJyqMqOrtClGZxIQbZ3w28NfyOEIFeOy7mFqnhr dJ95Mxc1ZRjXRvjqFIsFAFTrBbNBmQOPxBp7iA87JBINhEIBtGsEydznFGC347wWnHXB GSzQ== X-Forwarded-Encrypted: i=1; AJvYcCUaeHhLpTv/4Jvqdg6A6I0t0lgVuGSY3QOAI8eFR1TxatGrRujDjRkvCGXRB7QyA6gAiAK8gc5GrNqoMIM=@vger.kernel.org X-Gm-Message-State: AOJu0Ywgbb9GVK8VM3cme3gI5Fc3090ymO6/B6mcigwZHbwZ+nXF5bQJ Jh0LmAT03RrSastZzQ+M6uC+oU1Z9Jjv30G6ndrv8MQVDYVQqmIL8+Ej0q8REa8BkQsWt2pGmVp RrMq44VLhtB/48YerSEyv+2HUqJGmGbSK18z8nM7aDGY/E0AQW+nu4nGPJLcvjg== X-Gm-Gg: ASbGnctTWvQleWF7SGStRcmxP24J0147DMYL1pufcaFFMTrIH89Js1JevgAM/yWwd25 /WrlKLIQhQ6jhBz1gjICwhmCijEZAJJt433imR4XoSQ+7VuTnqVtLF/9SRfO6wPvZ4PAG3HhU8c hRx7dAAj7wRViRoxtJ28kpqrgbx2sLu/ZgcML8fB+JvqVGF8V+I4DkiunDfxUVqRQQoH5Qg6S99 SURH5MFXM8fS6gQCB58V63iIbj6E5YosaS3Zs0hoDDsnMGzaV0dNK4t6dDI X-Received: by 2002:a05:6602:15c4:b0:847:4d2b:c801 with SMTP id ca18e2360f4ac-8499e83514emr1422316339f.4.1735926269911; Fri, 03 Jan 2025 09:44:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IGu3BpX2PdS7QzM0Su8SzwKRFBMD1Cg1PPXO+4xkYW0ad+NnSpTjodno5nXHYSFgJEMCAWs9g== X-Received: by 2002:a05:6602:15c4:b0:847:4d2b:c801 with SMTP id ca18e2360f4ac-8499e83514emr1422316039f.4.1735926269563; Fri, 03 Jan 2025 09:44:29 -0800 (PST) Received: from redhat.com ([38.15.36.11]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e68c21a232sm7720813173.145.2025.01.03.09.44.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jan 2025 09:44:29 -0800 (PST) Date: Fri, 3 Jan 2025 10:44:27 -0700 From: Alex Williamson To: Tomita Moeko Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] vfio/pci: update igd matching conditions Message-ID: <20250103104427.55f1c73b.alex.williamson@redhat.com> In-Reply-To: <20241230161054.3674-2-tomitamoeko@gmail.com> References: <20241230161054.3674-2-tomitamoeko@gmail.com> X-Mailer: Claws Mail 4.3.0 (GTK 3.24.43; x86_64-redhat-linux-gnu) 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-Transfer-Encoding: 7bit On Tue, 31 Dec 2024 00:10:54 +0800 Tomita Moeko wrote: > igd device can either expose as a VGA controller or display controller > depending on whether it is configured as the primary display device in > BIOS. In both cases, the OpRegion may be present. Also checks if the > device is at bdf 00:02.0 to avoid setting up igd-specific regions on > Intel discrete GPUs. > > Signed-off-by: Tomita Moeko > --- > Changelog: > v2: > Fix misuse of pci_get_domain_bus_and_slot(), now only compares bdf > without touching device reference count. > Link: https://lore.kernel.org/all/20241229155140.7434-1-tomitamoeko@gmail.com/ > > drivers/vfio/pci/vfio_pci.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c > index e727941f589d..906a1db46d15 100644 > --- a/drivers/vfio/pci/vfio_pci.c > +++ b/drivers/vfio/pci/vfio_pci.c > @@ -111,9 +111,11 @@ static int vfio_pci_open_device(struct vfio_device *core_vdev) > if (ret) > return ret; > > - if (vfio_pci_is_vga(pdev) && > - pdev->vendor == PCI_VENDOR_ID_INTEL && > - IS_ENABLED(CONFIG_VFIO_PCI_IGD)) { > + if (IS_ENABLED(CONFIG_VFIO_PCI_IGD) && > + (pdev->vendor == PCI_VENDOR_ID_INTEL) && > + (((pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA) || > + ((pdev->class >> 8) == PCI_CLASS_DISPLAY_OTHER)) && > + (pci_dev_id(pdev) == PCI_DEVID(0, PCI_DEVFN(2, 0)))) { Sorry I wasn't available to reply on previous thread before v2 was posted, but given that we have vfio_pci_is_vga() we should use it rather than duplicate the contents. I think that suggests we should create a similar helper for display_other. Alternatively we should maybe consider if it's sufficient to use just the base class. The DEVID of course does not include the domain, which make it a rather suspect check already. What do the discrete cards report at 0xfc in config space? If it's zero or -1 or points to something that we can't memremap() or points to contents that doesn't include the opregion signature, then we'll already exit out of vfio_pci_igd_init(). Is there actually a case that we're actually configuring IGD specific regions for a discrete card? Thanks, Alex > ret = vfio_pci_igd_init(vdev); > if (ret && ret != -ENODEV) { > pci_warn(pdev, "Failed to setup Intel IGD regions\n");