From: Sui Jingfeng <sui.jingfeng@linux.dev>
To: Bjorn Helgaas <bhelgaas@google.com>,
Gerd Hoffmann <kraxel@redhat.com>,
Gurchetan Singh <gurchetansingh@chromium.org>,
Chia-I Wu <olvaffe@gmail.com>
Cc: dri-devel@lists.freedesktop.org, linux-pci@vger.kernel.org,
linux-kernel@vger.kernel.org,
virtualization@lists.linux-foundation.org,
Sui Jingfeng <suijingfeng@loongson.cn>,
"Maciej W. Rozycki" <macro@orcam.me.uk>,
Mario Limonciello <mario.limonciello@amd.com>
Subject: [-next 2/5] PCI/VGA: Deal with VGA devices
Date: Wed, 30 Aug 2023 19:15:29 +0800 [thread overview]
Message-ID: <20230830111532.444535-3-sui.jingfeng@linux.dev> (raw)
In-Reply-To: <20230830111532.444535-1-sui.jingfeng@linux.dev>
From: Sui Jingfeng <suijingfeng@loongson.cn>
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" <macro@orcam.me.uk>
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Sui Jingfeng <suijingfeng@loongson.cn>
---
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;
--
2.34.1
next prev parent reply other threads:[~2023-08-30 19:03 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-30 11:15 [-next 0/5] Add the pci_is_vga() helper and use it Sui Jingfeng
2023-08-30 11:15 ` [-next 1/5] PCI: Add the pci_is_vga() helper Sui Jingfeng
2023-10-05 22:51 ` Bjorn Helgaas
2023-10-06 11:40 ` Sui Jingfeng
2023-10-06 12:10 ` Maciej W. Rozycki
2023-08-30 11:15 ` Sui Jingfeng [this message]
2023-08-30 11:15 ` [-next 3/5] PCI/sysfs: Use " Sui Jingfeng
2023-08-30 11:15 ` [-next 4/5] drm/virgpu: Switch to pci_is_vga() Sui Jingfeng
2023-10-05 21:57 ` Bjorn Helgaas
2023-10-05 22:10 ` Bjorn Helgaas
2023-10-06 11:22 ` Sui Jingfeng
2023-08-30 11:15 ` [-next 5/5] drm/qxl: " Sui Jingfeng
2023-10-06 22:19 ` [-next 0/5] Add the pci_is_vga() helper and use it Bjorn Helgaas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230830111532.444535-3-sui.jingfeng@linux.dev \
--to=sui.jingfeng@linux.dev \
--cc=bhelgaas@google.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=gurchetansingh@chromium.org \
--cc=kraxel@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=macro@orcam.me.uk \
--cc=mario.limonciello@amd.com \
--cc=olvaffe@gmail.com \
--cc=suijingfeng@loongson.cn \
--cc=virtualization@lists.linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox