From patchwork Fri Jun 9 10:33:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sui Jingfeng X-Patchwork-Id: 105541 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp852041vqr; Fri, 9 Jun 2023 03:43:50 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6MoQpUPsy3s+FoEgeIBdu5hisXYHFz+nmo5xluVQlXyBmdDxYFnAz/rxMqh/SAZUKRdsSP X-Received: by 2002:a05:6a00:234c:b0:663:13a9:9504 with SMTP id j12-20020a056a00234c00b0066313a99504mr1141440pfj.10.1686307430603; Fri, 09 Jun 2023 03:43:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686307430; cv=none; d=google.com; s=arc-20160816; b=FPo0s14PiCAG/WzzZxptCT1xos1Ive3Hx4RpWh5d1Qn9RFP0qYjUHUdyvpjgyFoxBr I6PMfDRc2J43/5W8mmTo4FyuQC2ltbRIWHPJWWXT7NFw7eUAnB9fCY7TRIxJxvUkwWnT kDUzPR1Ls27wPuJaBGFLgxuTF4xE3w4bXOXn8nMRbZQMCzqvsjyrfeUF77XBWh3TTZZ0 FPPObpvwd02KrsZ+oHXOXJ4HUnfMVoZmmNR4kjCmIZ5v30IJMgxOf3KG0rVzcpbicXag Z9guj4VXczeG6VbPHeWsC5pJ1vU3nQOBreLdrR58BnEg7oxLSxJ1N5nE0UqOGvOGNi4V QOzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=POXJdxH9sawHXnvoaaPT1/oRjDgQ694BkgyuUEBMbGw=; b=BPSnF8sN1LPSDPvCRlUjxsFSwdz+VlNp06xtKlLsKSwQXW2/+8f/r7LbzKZ4ScKyrt /wGxWp19GPRSX74cuECbxbmc46ilYbZgB0cDcRX/XQ4mfJJoc2XOLI2/Ok1LevnxNo1V ko+FSYRzpl83RORXqi5pebqUi/vHmz25iE+xogiy5xnhFmwjYqEEMLyYzl/iyw/+eTru O8qd5Oc6pCRAORiDXhj0qhjvds6CEfLrMkSfd4Uuu/uTFuRLZXBPjxtMg4BVnn2u1fth puRV8Xph9IpB9DmdelD9kOOfeIe5wrYspnddmrAe5fWGwoVuhGJ40B2tYRiC1zO6xlyt UDgA== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 204-20020a6217d5000000b0062d7d3c6cadsi2227124pfx.333.2023.06.09.03.43.37; Fri, 09 Jun 2023 03:43:50 -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 S239375AbjFIKgo (ORCPT + 99 others); Fri, 9 Jun 2023 06:36:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238873AbjFIKgN (ORCPT ); Fri, 9 Jun 2023 06:36:13 -0400 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3305F1FDE; Fri, 9 Jun 2023 03:33:24 -0700 (PDT) Received: from loongson.cn (unknown [10.20.42.43]) by gateway (Coremail) with SMTP id _____8DxAOny_4JkqQYBAA--.1281S3; Fri, 09 Jun 2023 18:33:22 +0800 (CST) Received: from openarena.loongson.cn (unknown [10.20.42.43]) by localhost.localdomain (Coremail) with SMTP id AQAAf8DxGOXy_4JkMcQKAA--.32986S3; Fri, 09 Jun 2023 18:33:22 +0800 (CST) From: Sui Jingfeng To: Bjorn Helgaas , David Airlie , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [PATCH v4 2/4] PCI/VGA: Deal only with VGA class devices Date: Fri, 9 Jun 2023 18:33:19 +0800 Message-Id: <20230609103321.629192-2-suijingfeng@loongson.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230609103321.629192-1-suijingfeng@loongson.cn> References: <20230609103321.629192-1-suijingfeng@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: AQAAf8DxGOXy_4JkMcQKAA--.32986S3 X-CM-SenderInfo: xvxlyxpqjiv03j6o00pqjv00gofq/ X-Coremail-Antispam: 1Uk129KBj93XoW7WFW8Kr47tw4kJw1xCFy8WFX_yoW8KF1Dpa yfJFWrKry8Ww17Ga12qF1kZF15ZrZ2ya4ftr4Ik34SkFZIkrW0qasYk345A34fJrZ5GF1x tay2yF1UXw47GabCm3ZEXasCq-sJn29KB7ZKAUJUUUU3529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUBSb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1Y6r17M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Gr0_Xr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVCY1x0267AK xVWxJr0_GcWln4kS14v26r126r1DM2AIxVAIcxkEcVAq07x20xvEncxIr21l57IF6xkI12 xvs2x26I8E6xACxx1l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1q 6rW5McIj6I8E87Iv67AKxVWxJVW8Jr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7V AKI48JMxkF7I0En4kS14v26r126r1DMxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY 6r1j6r4UMxCIbckI1I0E14v26r126r1DMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7 xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUtVW8ZwCIc40Y0x0EwIxGrwCI42IY6xII jxv20xvE14v26r4j6ryUMIIF0xvE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwCI42IY6xAIw2 0EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Cr0_Gr1UMIIF0xvEx4A2jsIEc7Cj xVAFwI0_Gr1j6F4UJbIYCTnIWIevJa73UjIFyTuYvjxU28nYUUUUU X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768221500386743129?= X-GMAIL-MSGID: =?utf-8?q?1768221500386743129?= Deal only with the VGA devcie(pdev->class == 0x0300), so replace the pci_get_subsys() function with pci_get_class(). Filter the non-PCI display device(pdev->class != 0x0300) out. There no need to process the non-display PCI device. 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 c1bc6c983932..22a505e877dc 100644 --- a/drivers/pci/vgaarb.c +++ b/drivers/pci/vgaarb.c @@ -754,10 +754,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) { @@ -1500,7 +1496,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 != PCI_CLASS_DISPLAY_VGA << 8) + 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 @@ -1510,6 +1508,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; @@ -1534,8 +1534,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;