From patchwork Wed Aug 30 11:15:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sui Jingfeng X-Patchwork-Id: 1827971 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=J59qCFT0; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2620:137:e000::1:20; helo=out1.vger.email; envelope-from=linux-pci-owner@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by legolas.ozlabs.org (Postfix) with ESMTP id 4RbY9D3GVDz1yhf for ; Thu, 31 Aug 2023 04:44:00 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238814AbjH3SjP (ORCPT ); Wed, 30 Aug 2023 14:39:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243664AbjH3LYg (ORCPT ); Wed, 30 Aug 2023 07:24:36 -0400 Received: from out-252.mta0.migadu.com (out-252.mta0.migadu.com [IPv6:2001:41d0:1004:224b::fc]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 211F6CD7 for ; Wed, 30 Aug 2023 04:24:31 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1693394144; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DLVdHbG85+44P7qsiRYYVxfolXMOcHBsopMctAcePck=; b=J59qCFT0OBGdEmbDi4JY96Y0g2lOm/hwpx206PWQver8wN02CSpISQoonof/5wEaRuSTR5 ouCPVB3GdJM3Uyt4LGtJGwvB4wkGB4hupMSzjpaR//dtI0uBmIqZbmOBuyKnZ/kB5JxLUi kgv1cwNYtl3n58wormShqGG2v91FWKM= From: Sui Jingfeng To: Bjorn Helgaas , Gerd Hoffmann , Gurchetan Singh , Chia-I Wu Cc: dri-devel@lists.freedesktop.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, Sui Jingfeng , "Maciej W. Rozycki" Subject: [-next 1/5] PCI: Add the pci_is_vga() helper Date: Wed, 30 Aug 2023 19:15:28 +0800 Message-Id: <20230830111532.444535-2-sui.jingfeng@linux.dev> In-Reply-To: <20230830111532.444535-1-sui.jingfeng@linux.dev> References: <20230830111532.444535-1-sui.jingfeng@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org 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 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; + + return false; +} + #define for_each_pci_bridge(dev, bus) \ list_for_each_entry(dev, &bus->devices, bus_list) \ if (!pci_is_bridge(dev)) {} else From patchwork Wed Aug 30 11:15:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sui Jingfeng X-Patchwork-Id: 1827965 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=mcBA/F25; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2620:137:e000::1:20; helo=out1.vger.email; envelope-from=linux-pci-owner@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by legolas.ozlabs.org (Postfix) with ESMTP id 4RbY9511Xcz1ygM for ; Thu, 31 Aug 2023 04:43:53 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238757AbjH3SjI (ORCPT ); Wed, 30 Aug 2023 14:39:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243665AbjH3LYg (ORCPT ); Wed, 30 Aug 2023 07:24:36 -0400 Received: from out-251.mta0.migadu.com (out-251.mta0.migadu.com [91.218.175.251]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 365F6CDA for ; Wed, 30 Aug 2023 04:24:31 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1693394147; 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=duMfcSX8fViHE4Nde8EnuLeu99bLF0srnO8TViASf/g=; b=mcBA/F25UOYO/KXJJ64vjpnG+5RuiwByGc4xNO5cbK45vy4PlO3ZPV/X4BtfQnP0FAAde1 VDqD/IWTzwtopdOE1yBNJzg+V1RDwrfmfWBFny8QuamUf7qfc18SkgIQ/YrA0AdE80FdTb n3mRig5+pwFqLgnMMXd33NhWAcmuYQg= From: Sui Jingfeng To: Bjorn Helgaas , Gerd Hoffmann , Gurchetan Singh , Chia-I Wu Cc: dri-devel@lists.freedesktop.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, Sui Jingfeng , "Maciej W. Rozycki" , Mario Limonciello Subject: [-next 2/5] PCI/VGA: Deal with VGA devices Date: Wed, 30 Aug 2023 19:15:29 +0800 Message-Id: <20230830111532.444535-3-sui.jingfeng@linux.dev> In-Reply-To: <20230830111532.444535-1-sui.jingfeng@linux.dev> References: <20230830111532.444535-1-sui.jingfeng@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, 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 lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: Sui Jingfeng VGAARB only cares about PCI(e) VGA devices, thus filtering out unqualified devices as early as possible. This also means that deleting a non-VGA device snooped won't unnecessarily call into vga_arbiter_del_pci_device() function. By using the newly implemented pci_is_vga(), PCI(e) with PCI_CLASS_NOT_DEFINED_VGA class code will also be handled. Cc: "Maciej W. Rozycki" Reviewed-by: Mario Limonciello Signed-off-by: Sui Jingfeng --- drivers/pci/vgaarb.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/pci/vgaarb.c b/drivers/pci/vgaarb.c index 5e6b1eb54c64..ef8fe685de67 100644 --- a/drivers/pci/vgaarb.c +++ b/drivers/pci/vgaarb.c @@ -764,10 +764,6 @@ static bool vga_arbiter_add_pci_device(struct pci_dev *pdev) struct pci_dev *bridge; u16 cmd; - /* Only deal with VGA class devices */ - if ((pdev->class >> 8) != PCI_CLASS_DISPLAY_VGA) - return false; - /* Allocate structure */ vgadev = kzalloc(sizeof(struct vga_device), GFP_KERNEL); if (vgadev == NULL) { @@ -1503,6 +1499,9 @@ static int pci_notify(struct notifier_block *nb, unsigned long action, vgaarb_dbg(dev, "%s\n", __func__); + if (!pci_is_vga(pdev)) + return 0; + /* * For now, we're only interested in devices added and removed. * I didn't test this thing here, so someone needs to double check @@ -1537,8 +1536,8 @@ static struct miscdevice vga_arb_device = { static int __init vga_arb_device_init(void) { + struct pci_dev *pdev = NULL; int rc; - struct pci_dev *pdev; rc = misc_register(&vga_arb_device); if (rc < 0) @@ -1547,11 +1546,11 @@ static int __init vga_arb_device_init(void) bus_register_notifier(&pci_bus_type, &pci_notifier); /* Add all VGA class PCI devices by default */ - pdev = NULL; - while ((pdev = - pci_get_subsys(PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, - PCI_ANY_ID, pdev)) != NULL) - vga_arbiter_add_pci_device(pdev); + do { + pdev = pci_get_subsys(PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, pdev); + if (pci_is_vga(pdev)) + vga_arbiter_add_pci_device(pdev); + } while (pdev); pr_info("loaded\n"); return rc; From patchwork Wed Aug 30 11:15:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sui Jingfeng X-Patchwork-Id: 1827960 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=jv3CuduP; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2620:137:e000::1:20; helo=out1.vger.email; envelope-from=linux-pci-owner@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by legolas.ozlabs.org (Postfix) with ESMTP id 4RbY3H51LPz1yZs for ; Thu, 31 Aug 2023 04:38:51 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236620AbjH3Sit (ORCPT ); Wed, 30 Aug 2023 14:38:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243669AbjH3LYi (ORCPT ); Wed, 30 Aug 2023 07:24:38 -0400 Received: from out-246.mta0.migadu.com (out-246.mta0.migadu.com [IPv6:2001:41d0:1004:224b::f6]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 56D54CDD for ; Wed, 30 Aug 2023 04:24:32 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1693394149; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7Zg38/yfbHtNqcp81DKpY9eh6KOeHZbhiShVOmvA7V4=; b=jv3CuduPEnOmyI8RCuaM2tOrlJYrgKnWrIgY/SGdnDCtIaD1737g7qQZj11M3sQabQuS/T Nrx3PYIJaQeoUy4Eri1cT6M1NSRWACUCi8EUJw28uZQTTHIp051FWT1KU2Nxjfory8qhWa amSavgZwh8A/3Nlh1prwwA4ytPWkdqQ= From: Sui Jingfeng To: Bjorn Helgaas , Gerd Hoffmann , Gurchetan Singh , Chia-I Wu Cc: dri-devel@lists.freedesktop.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, Sui Jingfeng , "Maciej W. Rozycki" Subject: [-next 3/5] PCI/sysfs: Use pci_is_vga() helper Date: Wed, 30 Aug 2023 19:15:30 +0800 Message-Id: <20230830111532.444535-4-sui.jingfeng@linux.dev> In-Reply-To: <20230830111532.444535-1-sui.jingfeng@linux.dev> References: <20230830111532.444535-1-sui.jingfeng@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, 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 lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: Sui Jingfeng Instead of accessing the PCI_CLASS_DISPLAY_VGA and pdev->class directly. The PCI_CLASS_NOT_DEFINED_VGA is defined to provide backward compatibility for devices that were built before the class code field was defined. It should be visiable via sysfs(boot_vga) as the normal VGA-compatible devices. Cc: "Maciej W. Rozycki" Signed-off-by: Sui Jingfeng --- drivers/pci/pci-sysfs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index d9eede2dbc0e..522708938563 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c @@ -1552,10 +1552,10 @@ static umode_t pci_dev_attrs_are_visible(struct kobject *kobj, struct pci_dev *pdev = to_pci_dev(dev); if (a == &dev_attr_boot_vga.attr) - if ((pdev->class >> 8) != PCI_CLASS_DISPLAY_VGA) - return 0; + if (pci_is_vga(pdev)) + return a->mode; - return a->mode; + return 0; } static struct attribute *pci_dev_hp_attrs[] = { From patchwork Wed Aug 30 11:15:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sui Jingfeng X-Patchwork-Id: 1827967 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=BKbMYeKu; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2620:137:e000::1:20; helo=out1.vger.email; envelope-from=linux-pci-owner@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by legolas.ozlabs.org (Postfix) with ESMTP id 4RbY971mDVz1ygP for ; Thu, 31 Aug 2023 04:43:55 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236805AbjH3SjH (ORCPT ); Wed, 30 Aug 2023 14:39:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243667AbjH3LYh (ORCPT ); Wed, 30 Aug 2023 07:24:37 -0400 Received: from out-251.mta0.migadu.com (out-251.mta0.migadu.com [91.218.175.251]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42AC4CDB for ; Wed, 30 Aug 2023 04:24:32 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1693394151; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pgG068lwbSrL85NgvUHE0qbc19Xz9h3Wp1jv9CrKb5c=; b=BKbMYeKuNn9w8yBXx4KLlXqnPUTn8v0BW6xul9d3yqsah7BbL6O/ml1fXOw1/5XOVj3U3O qWMzRKfVm8NU8K/LEsd0wKIobhbEriwxUla5mUczR2uSAalvqYFba+ZXVu7C8kfPwBF4co kiTbzT5nv73FUV61tfctQ3srW3fnE6c= From: Sui Jingfeng To: Bjorn Helgaas , Gerd Hoffmann , Gurchetan Singh , Chia-I Wu Cc: dri-devel@lists.freedesktop.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, Sui Jingfeng , David Airlie , Daniel Vetter Subject: [-next 4/5] drm/virgpu: Switch to pci_is_vga() Date: Wed, 30 Aug 2023 19:15:31 +0800 Message-Id: <20230830111532.444535-5-sui.jingfeng@linux.dev> In-Reply-To: <20230830111532.444535-1-sui.jingfeng@linux.dev> References: <20230830111532.444535-1-sui.jingfeng@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, 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 lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: Sui Jingfeng Should be no functional change, just for cleanup purpose. Cc: David Airlie Cc: Gerd Hoffmann Cc: Gurchetan Singh Cc: Chia-I Wu Cc: Daniel Vetter Signed-off-by: Sui Jingfeng --- drivers/gpu/drm/virtio/virtgpu_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.c b/drivers/gpu/drm/virtio/virtgpu_drv.c index add075681e18..3a368304475a 100644 --- a/drivers/gpu/drm/virtio/virtgpu_drv.c +++ b/drivers/gpu/drm/virtio/virtgpu_drv.c @@ -51,7 +51,7 @@ static int virtio_gpu_pci_quirk(struct drm_device *dev) { struct pci_dev *pdev = to_pci_dev(dev->dev); const char *pname = dev_name(&pdev->dev); - bool vga = (pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA; + bool vga = pci_is_vga(pdev); int ret; DRM_INFO("pci: %s detected at %s\n", From patchwork Wed Aug 30 11:15:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sui Jingfeng X-Patchwork-Id: 1827964 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=DQIPbHXj; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2620:137:e000::1:20; helo=out1.vger.email; envelope-from=linux-pci-owner@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by legolas.ozlabs.org (Postfix) with ESMTP id 4RbY3Z2MV3z1ygP for ; Thu, 31 Aug 2023 04:39:06 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238671AbjH3Six (ORCPT ); Wed, 30 Aug 2023 14:38:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243661AbjH3LYf (ORCPT ); Wed, 30 Aug 2023 07:24:35 -0400 X-Greylist: delayed 525 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Wed, 30 Aug 2023 04:24:31 PDT Received: from out-245.mta0.migadu.com (out-245.mta0.migadu.com [IPv6:2001:41d0:1004:224b::f5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06BB1185 for ; Wed, 30 Aug 2023 04:24:31 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1693394153; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yb+XrAs7p/uVFQHI/WIGJJnBL8UHr9s0W2yc+Aw9HB8=; b=DQIPbHXjCEL1XRjgI8qUIGrjENjBVN+8g0H3qkTlRv717qujOhlbI9f+qb7WgC0HTu7QOb VjyHUqq8o/liZ/z0nM++7ft8suZFkjs9/5dLwbuH9A2fg2mBgYjKd5q2bDT24iINXpmHAw 9/WBfPgfyJ3eM/e/WPmvRCpLd8xkXzY= From: Sui Jingfeng To: Bjorn Helgaas , Gerd Hoffmann , Gurchetan Singh , Chia-I Wu Cc: dri-devel@lists.freedesktop.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, Sui Jingfeng , Dave Airlie , David Airlie , Daniel Vetter Subject: [-next 5/5] drm/qxl: Switch to pci_is_vga() Date: Wed, 30 Aug 2023 19:15:32 +0800 Message-Id: <20230830111532.444535-6-sui.jingfeng@linux.dev> In-Reply-To: <20230830111532.444535-1-sui.jingfeng@linux.dev> References: <20230830111532.444535-1-sui.jingfeng@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: Sui Jingfeng Should be no functional change, just for cleanup purpose. Cc: Dave Airlie Cc: Gerd Hoffmann Cc: David Airlie Cc: Daniel Vetter Signed-off-by: Sui Jingfeng --- drivers/gpu/drm/qxl/qxl_drv.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c index a3b83f89e061..08586bd2448f 100644 --- a/drivers/gpu/drm/qxl/qxl_drv.c +++ b/drivers/gpu/drm/qxl/qxl_drv.c @@ -68,11 +68,6 @@ module_param_named(num_heads, qxl_num_crtc, int, 0400); static struct drm_driver qxl_driver; static struct pci_driver qxl_pci_driver; -static bool is_vga(struct pci_dev *pdev) -{ - return pdev->class == PCI_CLASS_DISPLAY_VGA << 8; -} - static int qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { @@ -100,7 +95,7 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) if (ret) goto disable_pci; - if (is_vga(pdev) && pdev->revision < 5) { + if (pci_is_vga(pdev) && pdev->revision < 5) { ret = vga_get_interruptible(pdev, VGA_RSRC_LEGACY_IO); if (ret) { DRM_ERROR("can't get legacy vga ioports\n"); @@ -131,7 +126,7 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) unload: qxl_device_fini(qdev); put_vga: - if (is_vga(pdev) && pdev->revision < 5) + if (pci_is_vga(pdev) && pdev->revision < 5) vga_put(pdev, VGA_RSRC_LEGACY_IO); disable_pci: pci_disable_device(pdev); @@ -159,7 +154,7 @@ qxl_pci_remove(struct pci_dev *pdev) drm_dev_unregister(dev); drm_atomic_helper_shutdown(dev); - if (is_vga(pdev) && pdev->revision < 5) + if (pci_is_vga(pdev) && pdev->revision < 5) vga_put(pdev, VGA_RSRC_LEGACY_IO); }