Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1473691rwd; Thu, 8 Jun 2023 19:32:26 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5x8dN9NAN+MHVSjnNpBFlYw143F6hTzMEU6ksr0s2u6W3u/0TYq8+C2A0CafqjDMtpETjO X-Received: by 2002:a05:6358:9f92:b0:129:bfd3:994 with SMTP id fy18-20020a0563589f9200b00129bfd30994mr113851rwb.20.1686277945842; Thu, 08 Jun 2023 19:32:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686277945; cv=none; d=google.com; s=arc-20160816; b=PvP3Lw/bripDC8NOlaznGTjrGuJ5iysPaElQn/n0bzeZlTmnUQaxUtAkIVOnUCEtaH 4Tdhxdcg0cHeq3Eu4VtDLBt+iH+gNnYCxXVPkELmDlGSUA7YcJpDjmUJIFFZT7+GwnHn 0PnCjWDX5wJ14r72BrOP9zI27D+5JstTqx+YkCi6inOFZGcNJvh06jh0Ns76ybKB6zYw 1tmYWuAgieDW3/vZN4kKpG5X1NQXwcIvRyEgKZZO6hPq+HKFKXSadmEjRDTfY84Sq1Jg oMuEFrWoPQl+w6AQWm5Dj4JCeuvs1fKWWPZZARTubmTVKUvhvSDUuZfUTEAaA46ayVf9 R/FA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id; bh=YeNvSVVH06T2GwXrZdEz3yux9qwkN+IvXOBz26Mpt1I=; b=deS9GWKXxVJ6cgusBVQAdzn9PUob6tqQEJTNxt2ugpApsonKILgTVtEGmzkqB4PctK vGssjlmdn+YLfplz6iI+vT6SO/neQP25p6l/YCXCj+DSY4BmZPCoHyd2ap0LIRabDLRb r9nRGO9MWHsJVgaDtnKR9r55Tlmj2fHTlbT4eDu5CLG908PGw7PXA0hCexYiXF5nUsHv ttGKUrI9jsV0GboEj1HPEuwdNwtoZaDE/2kfmtVBZU1KmELC9NOA3zmxBylkewa8Ex1t D0jQTWER+WqILrKD3vF3T9YULdNEqaTJQ4APMue+FPPysJvnb9Sfhdl3m7WQbt/7IVRY tXVw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v29-20020a63b95d000000b005098590f1edsi1839138pgo.757.2023.06.08.19.32.13; Thu, 08 Jun 2023 19:32:25 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238437AbjFICM1 (ORCPT + 99 others); Thu, 8 Jun 2023 22:12:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238369AbjFICMW (ORCPT ); Thu, 8 Jun 2023 22:12:22 -0400 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E617E3AA4; Thu, 8 Jun 2023 19:11:47 -0700 (PDT) Received: from loongson.cn (unknown [10.20.42.43]) by gateway (Coremail) with SMTP id _____8DxCepYioJkBdgAAA--.2655S3; Fri, 09 Jun 2023 10:11:36 +0800 (CST) Received: from [10.20.42.43] (unknown [10.20.42.43]) by localhost.localdomain (Coremail) with SMTP id AQAAf8DxbMpXioJk2nYJAA--.20758S3; Fri, 09 Jun 2023 10:11:35 +0800 (CST) Message-ID: <83b2f92f-eab5-a19c-7d6b-3a70e66b9aae@loongson.cn> Date: Fri, 9 Jun 2023 10:11:34 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [Intel-gfx] [PATCH v3 3/4] PCI/VGA: only deal with VGA class devices Content-Language: en-US To: Bjorn Helgaas , 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 , 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 References: <20230608191221.GA1209912@bhelgaas> From: Sui Jingfeng Organization: Loongson In-Reply-To: <20230608191221.GA1209912@bhelgaas> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-CM-TRANSID: AQAAf8DxbMpXioJk2nYJAA--.20758S3 X-CM-SenderInfo: xvxlyxpqjiv03j6o00pqjv00gofq/ X-Coremail-Antispam: 1Uk129KBj93XoWxXrWDXr1fCry3ArW5uF4Dtrc_yoW5Kry8pa yrGayFkFW8W347Gry2qF4UZFyavrWkta4Syr4Yk34FkFWqkF18tFyrCry5Z343ArZ5GF1I qay2yF17Ww45tagCm3ZEXasCq-sJn29KB7ZKAUJUUUUd529EdanIXcx71UUUUU7KY7ZEX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CC_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 Hi, On 2023/6/9 03:12, Bjorn Helgaas wrote: > 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/ Will be fixed at next version, thanks for the strict checking, I will try to bring this rigorous to the other patch of myself in the future. > 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 :) I think, I probably should only do what I'm good at. The "good at" here means that It's under prepared, already matured with thinking(or consideration) by myself. And also including testing(on two or three architecture). That idea is belong to you, I would like to see how does it going to happen only. > 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 >> -- Jingfeng