From patchwork Fri Jun 30 10:23:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sui Jingfeng X-Patchwork-Id: 13297946 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4FD00EB64D7 for ; Fri, 30 Jun 2023 10:23:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232470AbjF3KXx (ORCPT ); Fri, 30 Jun 2023 06:23:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232562AbjF3KXu (ORCPT ); Fri, 30 Jun 2023 06:23:50 -0400 Received: from out-55.mta0.migadu.com (out-55.mta0.migadu.com [IPv6:2001:41d0:1004:224b::37]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB6CF2D55 for ; Fri, 30 Jun 2023 03:23:48 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1688120627; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=qn2GXzSHm2puRLoEUfB5VD8PuaCwtWVklsWXBuMQskI=; b=cYajXrKD/mWxV/Z+Jm4eYwbPHJDv3nUOTsg/RsGMTvw1WR+pfx3rnZs6S1PFr20H9uyLro 535XMh8Eu4bJWVm1PidfeUMbHbggjRA2UGbcvjh3rmGzJjyuJsvaAhvEH70u2WpIK/ZGpY NEZn2JwtNrr76IP1eBuPtjRQ8qayp/A= From: Sui Jingfeng To: Bjorn Helgaas Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Sui Jingfeng Subject: [PATCH 1/2] PCI/VGA: Move the new_state assignment out the loop Date: Fri, 30 Jun 2023 18:23:42 +0800 Message-Id: <20230630102342.134919-1-sui.jingfeng@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: Sui Jingfeng 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 --- 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); From patchwork Fri Jun 30 10:24:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sui Jingfeng X-Patchwork-Id: 13297948 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 286C0EB64D7 for ; Fri, 30 Jun 2023 10:33:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231724AbjF3Kdd (ORCPT ); Fri, 30 Jun 2023 06:33:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230178AbjF3Kdc (ORCPT ); Fri, 30 Jun 2023 06:33:32 -0400 X-Greylist: delayed 548 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Fri, 30 Jun 2023 03:33:31 PDT Received: from out-51.mta1.migadu.com (out-51.mta1.migadu.com [95.215.58.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99A083596 for ; Fri, 30 Jun 2023 03:33:31 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1688120662; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=8Qdp9pUoNDY5Mvuaf7+DmACBXhNJIeFau8zbx4GIwY4=; b=i/whvionwp7XeBI50BDtNvMp+ngKCUEzRxZds9j4ahAqhJmK6r1FRei7sRHniau8/OIylZ vkYcn7T9RIFYd2FTAJqNJPdp94Cw0Lh9dxWuAgFxtU0saOFKiEWU6uaZLWtLzP7g28/nL7 Tzv1xubl9tHNvhORMxE04c8sI/Lclpo= From: Sui Jingfeng To: Bjorn Helgaas Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Sui Jingfeng Subject: [PATCH 2/2] PCI/VGA: drop the inline of vga_update_device_decodes() function Date: Fri, 30 Jun 2023 18:24:12 +0800 Message-Id: <20230630102412.134977-1-sui.jingfeng@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: Sui Jingfeng The vga_update_device_decodes() is NOT a trivial function, nor performance critical. So drop the inline. Also keep the parameter and argument consistent. The second argument should declared as 'unsigned int' type. Signed-off-by: Sui Jingfeng --- drivers/pci/vgaarb.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/pci/vgaarb.c b/drivers/pci/vgaarb.c index cbd06bbf9dd7..17bd1268c36a 100644 --- a/drivers/pci/vgaarb.c +++ b/drivers/pci/vgaarb.c @@ -877,21 +877,21 @@ static bool vga_arbiter_del_pci_device(struct pci_dev *pdev) } /* This is called with the lock */ -static inline void vga_update_device_decodes(struct vga_device *vgadev, - int new_decodes) +static void vga_update_device_decodes(struct vga_device *vgadev, + unsigned int new_decodes) { struct device *dev = &vgadev->pdev->dev; - int old_decodes, decodes_removed, decodes_unlocked; + unsigned int old_decodes = vgadev->decodes; + unsigned int decodes_removed = ~new_decodes & old_decodes; + unsigned int decodes_unlocked = vgadev->locks & decodes_removed; - old_decodes = vgadev->decodes; - decodes_removed = ~new_decodes & old_decodes; - decodes_unlocked = vgadev->locks & decodes_removed; vgadev->decodes = new_decodes; - vgaarb_info(dev, "changed VGA decodes: olddecodes=%s,decodes=%s:owns=%s\n", - vga_iostate_to_str(old_decodes), - vga_iostate_to_str(vgadev->decodes), - vga_iostate_to_str(vgadev->owns)); + vgaarb_info(dev, + "VGA decodes changed: olddecodes=%s,decodes=%s:owns=%s\n", + vga_iostate_to_str(old_decodes), + vga_iostate_to_str(vgadev->decodes), + vga_iostate_to_str(vgadev->owns)); /* If we removed locked decodes, lock count goes to zero, and release */ if (decodes_unlocked) {