From: Sui Jingfeng <sui.jingfeng@linux.dev>
To: Bjorn Helgaas <bhelgaas@google.com>
Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
Sui Jingfeng <suijingfeng@loongson.cn>
Subject: [PATCH 1/2] PCI/VGA: Move the new_state assignment out the loop
Date: Fri, 30 Jun 2023 18:23:42 +0800 [thread overview]
Message-ID: <20230630102342.134919-1-sui.jingfeng@linux.dev> (raw)
From: Sui Jingfeng <suijingfeng@loongson.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@loongson.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
reply other threads:[~2023-06-30 10:23 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20230630102342.134919-1-sui.jingfeng@linux.dev \
--to=sui.jingfeng@linux.dev \
--cc=bhelgaas@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=suijingfeng@loongson.cn \
/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
all inboxes | Powered by JetHome®