From patchwork Fri Jun 9 11:24:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sui Jingfeng X-Patchwork-Id: 105569 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp886197vqr; Fri, 9 Jun 2023 04:52:10 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5+umWMhjuimjcqON5Fva92ek5XDpGkXUKmuBRHN5Rib0hbIVnquwgBJZD2Shy47vDxSJIF X-Received: by 2002:a05:6358:c416:b0:129:cf4e:c0e1 with SMTP id ff22-20020a056358c41600b00129cf4ec0e1mr867194rwb.32.1686311529830; Fri, 09 Jun 2023 04:52:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686311529; cv=none; d=google.com; s=arc-20160816; b=ZBLyYX8tswPO2c/5WJ3U1PpcPW9HXOwVUr2GiyXvx8PwFM+maKK2g9P/V6uOPPcWaN u8lYYSFbY7Cp44bBeQXaJ3dVM7Dp5NwkF1uDgVhMfXCIZSO8yMVD6LAnB+bD2B8KxzkA 9UhxelzVQtCktYZtJuhpdmzVMqt/WX/wTN69wNORfFKPzh7e+Z642g/H6Fisu7DHLlCM 2BtYLfJbqKJQQKgMqQARPsMDt0//5YcP0WOwVszx3pj/rPw1wDXz6pxIfUPUTSaLtCIU 6J5avQNxLgLMg+W1QsCzvvKNNKYdWLBJq67BYWVrYGmYgd4HXlPmbyTqOBTVAohbrI45 aQgg== 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=Hn+OjTMmyN+raJlTagObphKWUB5CqDLLTJ3oykH9yr9S/b+7NrpEiIQcBYBVUVvDri i68jWXJUDSu3ERhC/DPdvog/Dmx0f1a0vSRWTHhhQyKxdN8YBO/3AIa/pEAjP022QxIe Vix1zHWqylXglYpCgUGyN0NLmePcidAR4F2EVGTq8yn+Z26Zq+9Yv6Y/5Eq8OlJSBZY/ Q9jai5nayTSvTG3xVY+NDpevZjMvTr6+j9+pQ9IQUvevuORfFPWMRd3WaNpHLMkcRvfE K5essYSyFfVjTVCndDm8IaCxioRMXViE+vC2JX8tsdev9qaPSQBHGPseGj33+4K1wGx+ NLtw== 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 v12-20020a63b94c000000b0051b554df1c2si2623392pgo.497.2023.06.09.04.51.56; Fri, 09 Jun 2023 04:52: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; 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 S238944AbjFILY1 (ORCPT + 99 others); Fri, 9 Jun 2023 07:24:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237713AbjFILYW (ORCPT ); Fri, 9 Jun 2023 07:24:22 -0400 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 69FAA272A; Fri, 9 Jun 2023 04:24:20 -0700 (PDT) Received: from loongson.cn (unknown [10.20.42.43]) by gateway (Coremail) with SMTP id _____8DxCerhC4NkOgwBAA--.3144S3; Fri, 09 Jun 2023 19:24:17 +0800 (CST) Received: from openarena.loongson.cn (unknown [10.20.42.43]) by localhost.localdomain (Coremail) with SMTP id AQAAf8AxauXhC4NkbvEKAA--.33393S3; Fri, 09 Jun 2023 19:24:17 +0800 (CST) From: Sui Jingfeng To: Bjorn Helgaas , David Airlie , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Jani Nikula , Andi Shyti Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [PATCH v5 2/4] PCI/VGA: Deal only with VGA class devices Date: Fri, 9 Jun 2023 19:24:15 +0800 Message-Id: <20230609112417.632313-2-suijingfeng@loongson.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230609112417.632313-1-suijingfeng@loongson.cn> References: <20230609112417.632313-1-suijingfeng@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: AQAAf8AxauXhC4NkbvEKAA--.33393S3 X-CM-SenderInfo: xvxlyxpqjiv03j6o00pqjv00gofq/ X-Coremail-Antispam: 1Uk129KBj93XoW7WFW8Kr47tw4kJw1xCFy8WFX_yoW8KF1Dpa yfJFWrKry8Ww17Ga12qF1kZF15ZrZ2ya4ftr4Ik34SkFZIkrW0qasYk345A34fJrZ5GF1x tay2yF1UXw47GabCm3ZEXasCq-sJn29KB7ZKAUJUUUUt529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUBvb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r126r13M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Gr0_Xr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVCY1x0267AK xVWxJr0_GcWln4kS14v26r1q6r43M2AIxVAIcxkEcVAq07x20xvEncxIr21l57IF6xkI12 xvs2x26I8E6xACxx1l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1q 6rW5McIj6I8E87Iv67AKxVW8Jr0_Cr1UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x 0EwIxGrwCY1x0262kKe7AKxVW8ZVWrXwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkE bVWUJVW8JwCFI7km07C267AKxVWUAVWUtwC20s026c02F40E14v26r1j6r18MI8I3I0E74 80Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcVC0 I7IYx2IY67AKxVW8JVW5JwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04 k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r4UJVWxJr1lIxAIcVC2z280aVCY 1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x07jdcTPUUUUU= 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?1768225798349264746?= X-GMAIL-MSGID: =?utf-8?q?1768225798349264746?= 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;