Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp36115rdb; Thu, 5 Oct 2023 15:52:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IETUCMi/yAwi/yHxqpNZRqtEsbX+nVEVZt1FZoEMlvAEIk/0rBh8v7RG4YT/bCX78tPzmvx X-Received: by 2002:a17:903:1ca:b0:1c6:1a26:ef56 with SMTP id e10-20020a17090301ca00b001c61a26ef56mr8073917plh.48.1696546350992; Thu, 05 Oct 2023 15:52:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696546350; cv=none; d=google.com; s=arc-20160816; b=hL02Sq+Dv5t5nXR13q7yh9HzH6X9CxFf+Ipj9HXGQU2dh+UfAtQMg2j9Vt3brb6o1a gsmuVewhLhJfeVcVr4XWM4dXf6v9j67MB4Z1TatvTDwpA1YSu65VwGk6ftO6oBtxbmU3 tPT4XR0h8RrEau53rS6WgHyRqG/Mas6Onz9CLuys18E09nU5fYuL4xDDhQbKZOP83a3b 7VQ/0TCY7QeiwAEEPoKqdexjWbCAIMcsxx8P6xexEcoaAjscZ48/stjVRH2kWky0kR4m 5UNhPIy00EwA5or7vCivUQDMAZHINcSx+cADD5tY4SXtC0hNT5XS23B5omr8VvQhtbyE subQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=ki9dC1ijyN5SI7tTNCchC4nI0ZLrhqeJV1jeyBJmV2M=; fh=p11n9UaPcM6pCky4oGtQIwSMGPFdJ2j4fic3bFSJx5w=; b=07hhEp6pfWXhTHvZJtcLWBod6cwdMNEPuRorQFEeblryOKO+kB1Yy1NSd0zAnzRsc+ VWUv82OaqYC/gOwVmQtmi26EpU9iPK+OYf1lIv29Zl/feUeQ1FBXgZQjWbeJfVekf2By eioV6jhHM2IQhOybHQwsAnOQiv7T3meMHKFw88fLEGzv2Pz7NWSrjITvhZfOMPf7+xKr W+rSBzvt8T61cqHyI1MPIh+AvZXKTGKDq85eXSN38JoFtEY4MUj094vvDOmnemrQXvsD vf9ALykDTBhKZ/KyeQVdZxYgH3OdMz9epWLSLShuYF9yhwOSXsowMMgEzbbo4OoanDwo ciVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MNukphMS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id u13-20020a170902e80d00b001c3f96ec6d6si2683104plg.111.2023.10.05.15.52.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 15:52:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MNukphMS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id E59638078CA8; Thu, 5 Oct 2023 15:51:29 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231891AbjJEWvK (ORCPT + 99 others); Thu, 5 Oct 2023 18:51:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229527AbjJEWvJ (ORCPT ); Thu, 5 Oct 2023 18:51:09 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A92D5DE; Thu, 5 Oct 2023 15:51:03 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0C844C433C7; Thu, 5 Oct 2023 22:51:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696546263; bh=6Z+aNRTykgUl2shYjBKN3j99iPvZlR6BDg/SD2cELU8=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=MNukphMSInGVUe6e01X0aki2ed92AZyanoAXS1Tse2jkA9W3Ip2Vrq3qZXUuWFeAm 5THAUEv1ZFV7lRkX73pa5wFZbrMZVnBtOOADNoSVhDoSwvQbgRCf2ReCyg2FU8JDiw hJBi1H9FhrZ6OnSz/lmhK+ZlshRSG+Z1VQ5zHtoIInARuChulTjTyRksLL+HT8wYwb /b2wAQVwnnFrh5H08XEA415LtQagTLgi6HT7mMLSLLrpdJGnm+chWdfYEO2Pvwz94V kz4ubbn+i563g6Wk23YSZYGgBg7iCQAhlJKyFUj281GiAyrIznmNiSXnDuSpnsUr5o bPn9QBR7/7oXQ== Date: Thu, 5 Oct 2023 17:51:01 -0500 From: Bjorn Helgaas To: Sui Jingfeng Cc: Bjorn Helgaas , Gerd Hoffmann , Gurchetan Singh , Chia-I Wu , Sui Jingfeng , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, virtualization@lists.linux-foundation.org, "Maciej W. Rozycki" Subject: Re: [-next 1/5] PCI: Add the pci_is_vga() helper Message-ID: <20231005225101.GA792747@bhelgaas> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230830111532.444535-2-sui.jingfeng@linux.dev> X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Thu, 05 Oct 2023 15:51:30 -0700 (PDT) On Wed, Aug 30, 2023 at 07:15:28PM +0800, Sui Jingfeng wrote: > From: Sui Jingfeng > > The PCI code and ID assignment specification defined four types of > display controllers for the display base class(03h), and the devices > with 0x00h sub-class code are VGA devices. VGA devices with programming I can update this with the spec details (PCI Code and Assignment spec r1.15, secs 1.1 and 1.4). > interface 0x00 is VGA-compatible, VGA devices with programming interface > 0x01 are 8514-compatible controllers. Besides, PCI_CLASS_NOT_DEFINED_VGA > is defined to provide backward compatibility for devices that were built > before the class code field was defined. Hence, introduce the pci_is_vga() > helper, let it handle the details for us. It returns true if the PCI(e) > device being tested belongs to the VGA devices category. > > Cc: "Maciej W. Rozycki" > Signed-off-by: Sui Jingfeng > --- > include/linux/pci.h | 27 +++++++++++++++++++++++++++ > 1 file changed, 27 insertions(+) > > diff --git a/include/linux/pci.h b/include/linux/pci.h > index cf6e0b057752..ace727001911 100644 > --- a/include/linux/pci.h > +++ b/include/linux/pci.h > @@ -713,6 +713,33 @@ static inline bool pci_is_bridge(struct pci_dev *dev) > dev->hdr_type == PCI_HEADER_TYPE_CARDBUS; > } > > +/** > + * The PCI code and ID assignment specification defined four types of > + * display controllers for the display base class(03h), and the devices > + * with 0x00h sub-class code are VGA devices. VGA devices with programming > + * interface 0x00 is VGA-compatible, VGA devices with programming interface > + * 0x01 are 8514-compatible controllers. Besides, PCI_CLASS_NOT_DEFINED_VGA > + * is defined to provide backward compatibility for devices that were built > + * before the class code field was defined. This means that it belong to the > + * VGA devices category also. > + * > + * Returns: > + * true if the PCI device is a VGA device, false otherwise. > + */ > +static inline bool pci_is_vga(struct pci_dev *pdev) > +{ > + if (!pdev) > + return false; > + > + if ((pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA) > + return true; > + > + if ((pdev->class >> 8) == PCI_CLASS_NOT_DEFINED_VGA) > + return true; Are you seeing a problem that will be fixed by this series, i.e., a PCI_CLASS_NOT_DEFINED_VGA device that we currently don't handle correctly? I think this makes sense per the spec, but there's always a risk of breaking something, so it's nice if the change actually *fixes* something to make that risk worthwhile. > + return false; > +} > + > #define for_each_pci_bridge(dev, bus) \ > list_for_each_entry(dev, &bus->devices, bus_list) \ > if (!pci_is_bridge(dev)) {} else > -- > 2.34.1 >