Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1116810rwd; Thu, 8 Jun 2023 12:22:09 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4YXCuSVBFy0KYwb2/IxO2gIQdtrWJUwURiji2ydHjnDzHyCbX+L3bBQ5g0seMr3e0pp4vh X-Received: by 2002:a17:903:18e:b0:1ae:35b8:d5ae with SMTP id z14-20020a170903018e00b001ae35b8d5aemr3349132plg.19.1686252129636; Thu, 08 Jun 2023 12:22:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686252129; cv=none; d=google.com; s=arc-20160816; b=vGMl6zamjZxDIzjgvqu7YVlf79NxDwDYdyx/iMazW6er1Uwm4kriBjvJLRT7PnpeSO x81QqUJEpiDlsxP9NQJwqB03vegB5tHOfXo8rxTH1cuqDlJ2Qe2uJgO4sVxtFw4/u5uM Zd/FaqXda1NAfwPsdSdMkHsMFHPzXgMwfojUS4JAmBx8zMecdnEaPCNKF9ZU4ECqaqGw vsYFBJGgb9cHA5JXNURkNFX/b7NrQFDkDxiZg3dQ+SKIjqGJ7dUPTres2mKPBn2znli8 l7PcgCSCEDy3xlzeXZUHAez0hHw9rjwQ86+UUC6RfRsr/2BCu4SGyn6L8ecCjbW42Jli s1IQ== 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=lFJmVPTiUtstj/W8TK9aBHmy2yFmU5YnbbFKchCyGUE=; b=Bi0YnNz5zJiugNxsugdYs6uKAJoYT9bmMzrU/bjvL7eBweVpqE1nqX8FyPXTL5Cylm U6yRL3eVhv71CXO2LvUMncHbaf6KTL64tfweAHLXejuC6q+SjgUZAsk2T+FU1h8IFTNI 3cShtXHhCV21Hw//ckcz8PAI2FhxxWkmvet9hmbPRhdq4ta3NY+zkfwS2EFfMuBb5FxR YLtTL8GOb0u9lBDevbQjeiNxYztKXzzaZ68LjI+/Jc2/7838goTtyu2wjjVsSrxetpAy jQq/JZccYAHstbLfUfCoMFffLWDolR+cfaZV1w5lTE7cT2vqmVcBbJd/DXpwKgHOyAZ3 SBUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=T+IHeID0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jy8-20020a17090342c800b001b066c922d3si1392690plb.314.2023.06.08.12.21.57; Thu, 08 Jun 2023 12:22:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=T+IHeID0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235939AbjFHTMe (ORCPT + 99 others); Thu, 8 Jun 2023 15:12:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234171AbjFHTMc (ORCPT ); Thu, 8 Jun 2023 15:12:32 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0400530D2; Thu, 8 Jun 2023 12:12:25 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 221EC61554; Thu, 8 Jun 2023 19:12:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 29690C433D2; Thu, 8 Jun 2023 19:12:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686251543; bh=BjGgyC3wTO33c1Tdxatub3Rc/d6F/CPXBfd8u1gAIrU=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=T+IHeID0iP9vHKnUCZWCJZGQQf3diXJ9+HZsVX4IN+ITJMvEmanSAYv3Yzh8azF0B DwTD2hES7OI5X32J985zgUykL/VJC17J9RWkJQocx9kBsAVQUtN7/9qJ1fWYGoetMd eBQKXEF35moYax03HHpcg4x4OoiW4apuLCA/DkwSUiABGP3VEVW+25hBWARBeaZRfn BiZiRj0VAURoBIfb2OJNL2jBuXv0ll/9QSOt0PcLm9QxuSuC8Mpy9D+ED/455Mv1+8 xPYuNx2pM23hBbcf1UJIzRvvqqOOaawENsKWeMQoiXDErRHJ6Na0/r3eSuqIymPzgT jsqdCdkGNLeqg== Date: Thu, 8 Jun 2023 14:12:21 -0500 From: Bjorn Helgaas To: Sui Jingfeng <15330273260@189.cn> Cc: Alex Deucher , Christian Konig , Pan Xinhui , David Airlie , Daniel Vetter , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , Ben Skeggs , Karol Herbst , Lyude Paul , Bjorn Helgaas , Alex Williamson , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Hawking Zhang , Mario Limonciello , Lijo Lazar , YiPeng Chai , Andrey Grodzovsky , Somalapuram Amaranath , Bokun Zhang , Ville Syrjala , Li Yi , Sui Jingfeng , Jason Gunthorpe , Kevin Tian , Cornelia Huck , Yishai Hadas , Abhishek Sahu , Yi Liu , kvm@vger.kernel.org, nouveau@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, loongson-kernel@lists.loongnix.cn, amd-gfx@lists.freedesktop.org, linux-pci@vger.kernel.org Subject: Re: [Intel-gfx] [PATCH v3 3/4] PCI/VGA: only deal with VGA class devices Message-ID: <20230608191221.GA1209912@bhelgaas> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230608114322.604887-4-15330273260@189.cn> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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-kernel@vger.kernel.org Start with verb and capitalize to match ("Deal only with ...") On Thu, Jun 08, 2023 at 07:43:21PM +0800, Sui Jingfeng wrote: > From: Sui Jingfeng > > vgaarb only deal with the VGA devcie(pdev->class == 0x0300), so replace the > pci_get_subsys() function with pci_get_class(). Filter the non pci display > device out. There no need to process the non display PCI device. s/non pci/non-PCI/ s/non display/non-display/ This is fine, and I'll merge this, but someday I would like to get rid of the bus_register_notifier() and call vga_arbiter_add_pci_device() and vga_arbiter_del_pci_device() directly from the PCI core. Or if you wanted to do that now, that would be even better :) Bjorn > Signed-off-by: Sui Jingfeng > --- > drivers/pci/vgaarb.c | 22 ++++++++++++---------- > 1 file changed, 12 insertions(+), 10 deletions(-) > > diff --git a/drivers/pci/vgaarb.c b/drivers/pci/vgaarb.c > index 7f0347f4f6fd..b0bf4952a95d 100644 > --- a/drivers/pci/vgaarb.c > +++ b/drivers/pci/vgaarb.c > @@ -756,10 +756,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) { > @@ -1499,7 +1495,9 @@ static int pci_notify(struct notifier_block *nb, unsigned long action, > struct pci_dev *pdev = to_pci_dev(dev); > bool notify = false; > > - vgaarb_dbg(dev, "%s\n", __func__); > + /* Only deal with VGA class devices */ > + if ((pdev->class >> 8) != PCI_CLASS_DISPLAY_VGA) > + return 0; > > /* For now we're only intereted in devices added and removed. I didn't > * test this thing here, so someone needs to double check for the > @@ -1509,6 +1507,8 @@ static int pci_notify(struct notifier_block *nb, unsigned long action, > else if (action == BUS_NOTIFY_DEL_DEVICE) > notify = vga_arbiter_del_pci_device(pdev); > > + vgaarb_dbg(dev, "%s: action = %lu\n", __func__, action); > + > if (notify) > vga_arbiter_notify_clients(); > return 0; > @@ -1533,8 +1533,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) > @@ -1545,11 +1545,13 @@ static int __init vga_arb_device_init(void) > /* We add all PCI devices satisfying VGA class in the arbiter by > * default > */ > - pdev = NULL; > - while ((pdev = > - pci_get_subsys(PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, > - PCI_ANY_ID, pdev)) != NULL) > + while (1) { > + pdev = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, pdev); > + if (!pdev) > + break; > + > vga_arbiter_add_pci_device(pdev); > + }; > > pr_info("loaded\n"); > return rc; > -- > 2.25.1 >