[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20230630102342.134919-1-sui.jingfeng@linux.dev>
Date: Fri, 30 Jun 2023 18:23:42 +0800
From: Sui Jingfeng <sui.jingfeng@...ux.dev>
To: Bjorn Helgaas <bhelgaas@...gle.com>
Cc: linux-pci@...r.kernel.org, linux-kernel@...r.kernel.org,
Sui Jingfeng <suijingfeng@...ngson.cn>
Subject: [PATCH 1/2] PCI/VGA: Move the new_state assignment out the loop
From: Sui Jingfeng <suijingfeng@...ngson.cn>
In the vga_arbiter_notify_clients() function, the value of the 'new_state'
variable will be 'false' on the systems which have more than one PCI
display card. Its value will be 'true' on the systems which have only one
or no PCI display card. Its value is not relevant to the iteration, so move
the new_state assignment out the loop. For multiple video card systems this
could be an optimization.
Signed-off-by: Sui Jingfeng <suijingfeng@...ngson.cn>
---
drivers/pci/vgaarb.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/drivers/pci/vgaarb.c b/drivers/pci/vgaarb.c
index ceb914245383..cbd06bbf9dd7 100644
--- a/drivers/pci/vgaarb.c
+++ b/drivers/pci/vgaarb.c
@@ -1482,22 +1482,20 @@ static void vga_arbiter_notify_clients(void)
{
struct vga_device *vgadev;
unsigned long flags;
- uint32_t new_decodes;
- bool new_state;
+ bool state;
if (!vga_arbiter_used)
return;
+ state = (vga_count > 1) ? false : true;
+
spin_lock_irqsave(&vga_lock, flags);
list_for_each_entry(vgadev, &vga_list, list) {
- if (vga_count > 1)
- new_state = false;
- else
- new_state = true;
if (vgadev->set_decode) {
- new_decodes = vgadev->set_decode(vgadev->pdev,
- new_state);
- vga_update_device_decodes(vgadev, new_decodes);
+ unsigned int decodes;
+
+ decodes = vgadev->set_decode(vgadev->pdev, state);
+ vga_update_device_decodes(vgadev, decodes);
}
}
spin_unlock_irqrestore(&vga_lock, flags);
--
2.25.1
Powered by blists - more mailing lists