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.133.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 C7EE015CD4A for ; Sun, 29 Dec 2024 16:26:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735489568; cv=none; b=Q9PDdusF1wIdIQauAMiprxm1IuAg+BLvZ9GNP2tWzKiT/DnqCqkiJ3VUwQuEAagy+Bqbjs5QagoLx/tCQJFLFY7D/kHIFycpo3YqAzIUccso/232a7v6NcV/DQYoRheBApt6IsfuZeYl6BEr+s8Q2NBhwUqo/KVM0qtyryzOSuU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735489568; c=relaxed/simple; bh=HaNY+C8oP30vh3/L+YrE5useMaXWOGBiCcL5tROaxfs=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=sw1OT7TKjDH4YHX5cXGQcqIbWW/ESq1FLK1YgSL42DRLpjk6TmnvSr+wzEBpSZxOK7N4KlonmUy2hkPtrBAJAGsGx8XtnV/axlijXI8PzL2ZWGRmyg/9Ns7JbQDO0wBYVfmXaHUPWWXwB68AQjW4Ry4X0WrcDSriCukDVUhxJ/k= 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=Li1wmvhQ; arc=none smtp.client-ip=170.10.133.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="Li1wmvhQ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1735489565; 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=BP9CmBVdMWKyit113lefuy/9N9GsQCl9FPjSqRS+5JM=; b=Li1wmvhQJSS3JivjrZgZ5+wWcinKXVA/HgaEsPLGh8Wt1N70YgJbn7V8xzSONgzWNgqLMY hC2jXY0TR4fuDu6PaKE8IAH93XOqMnu6QRp8CA4VOjQs0EhsarwgHnD9TVamgWgszZvgFX 5wi5Kux12gEOi4kX2yoVtLHBkLqBer8= Received: from mail-il1-f199.google.com (mail-il1-f199.google.com [209.85.166.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-266-EEfY06WwOyyi-96AE8Ns0g-1; Sun, 29 Dec 2024 11:26:04 -0500 X-MC-Unique: EEfY06WwOyyi-96AE8Ns0g-1 X-Mimecast-MFC-AGG-ID: EEfY06WwOyyi-96AE8Ns0g Received: by mail-il1-f199.google.com with SMTP id e9e14a558f8ab-3a78fc19e2aso9910685ab.3 for ; Sun, 29 Dec 2024 08:26:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735489563; x=1736094363; h=content-transfer-encoding:mime-version:organization: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=BP9CmBVdMWKyit113lefuy/9N9GsQCl9FPjSqRS+5JM=; b=pQyRr0U453zlYhs3WjMRmbZcIpF/DYSdkaj4oPIfPIJkGsycnizq8gmLuY7kak8eLi VtAVcR7n3uGpTo8i9gxBmdUYZY53WStIfp+o7FAQ5Es+YvMs53I2Yw88e/u7xPmedfkt uTaRSIPqeRs7jhfV5/XtjESgqkX3x1YMPe0umQuC7+Q12G3ukCeUg11l9K6cmHDDfjXa 0BJN8SNeLHzeiw/XyIf+22Ut/8jIUvtUu1pGkp4LjmG2WM3CD9x7gQ3zZaSjPYT07bW0 gwWh0ueoiIMQfypSQwoS810Ipqo0nmUZYcsaqxRnE3b4Dnij5h/TkemAcf3Dqm9DzUeA 708Q== X-Forwarded-Encrypted: i=1; AJvYcCWCUlBDwbpVxtP2+eOYdcpN+KjyHbP3VrxYt5S4cLZejkO5o+LLTsQJ143R1MfO26a/uNgX+RWjdOBcfg0=@vger.kernel.org X-Gm-Message-State: AOJu0Yy1OThcb0fglE0IiMMlgPN6GnQp/j1adHQSODzDIJo2BV8P8Rdw 63GKQxPXswoDL3AewDoGMkwOKC/cQGgsjW2fzJlhB55P7MbUn752assyE7EQx5TC2SN36/BL5uO ctGyeE4LluvWLFPImUfhG8j1nNWvcGy2m75ZLL3sk/PRYLU9AV32SeDZUYAHhWw== X-Gm-Gg: ASbGnct466RvnuwDZhvBFdg5nPrJ21I/e8+o01oWHd5jLsKhJ5bG3DSlGfLMmzyvwwN eSTegct15J5oL8fJpkymi9tCaMCDHw/d7MfViv+y26tWg5Tpex/r35PluohPOeiAOHKC2ZDBOio 5kfc1kixB21q+QK+3y1DZgkVBsdbu+BPe21jR+JLMr01fQ0QE8AIX+L7VeC9ilIfOEn3PRKYl6V kg09fWNg33TllN+jafX8phr2jLaEmfAVaZ8xh1g5gAWrQy25Dfh/q7mwtQQ X-Received: by 2002:a05:6e02:1c81:b0:3a7:bd4c:b17e with SMTP id e9e14a558f8ab-3c2cbd89eedmr79536265ab.0.1735489563264; Sun, 29 Dec 2024 08:26:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IGhP2KVMR0b5CnCDmPD36tMrDG2mxii9UYCt/CB0wL//kHYEx0U43ymDHuzdL6EErDtqQf9XQ== X-Received: by 2002:a05:6e02:1c81:b0:3a7:bd4c:b17e with SMTP id e9e14a558f8ab-3c2cbd89eedmr79536225ab.0.1735489562947; Sun, 29 Dec 2024 08:26:02 -0800 (PST) Received: from redhat.com ([38.15.36.11]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e68bf4f33esm5063250173.19.2024.12.29.08.26.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Dec 2024 08:26:02 -0800 (PST) Date: Sun, 29 Dec 2024 09:26:00 -0700 From: Alex Williamson To: Tomita Moeko Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] vfio/pci: update igd matching conditions Message-ID: <20241229092600.00ffa55f.alex.williamson@redhat.com> In-Reply-To: <20241229155140.7434-1-tomitamoeko@gmail.com> References: <20241229155140.7434-1-tomitamoeko@gmail.com> Organization: Red Hat 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 Sun, 29 Dec 2024 23:51:40 +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 > --- > drivers/vfio/pci/vfio_pci.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c > index e727941f589d..051ef4ad3f43 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) && > + if (IS_ENABLED(CONFIG_VFIO_PCI_IGD) && > pdev->vendor == PCI_VENDOR_ID_INTEL && > - IS_ENABLED(CONFIG_VFIO_PCI_IGD)) { > + ((pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA || The above is vfio_pci_is_vga(pdev), maybe below should have a similar helper. > + (pdev->class >> 8) == PCI_CLASS_DISPLAY_OTHER) && > + pdev == pci_get_domain_bus_and_slot(0, 0, PCI_DEVFN(2, 0))) { This increments the reference count on the device: * Given a PCI domain, bus, and slot/function number, the desired PCI * device is located in the list of PCI devices. If the device is * found, its reference count is increased and this function returns a * pointer to its data structure. The caller must decrement the * reference count by calling pci_dev_put(). > ret = vfio_pci_igd_init(vdev); > if (ret && ret != -ENODEV) { > pci_warn(pdev, "Failed to setup Intel IGD regions\n");