Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp4922837rwb; Tue, 8 Aug 2023 16:46:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHESpxlf8Okji4G6994ulIxl49O0QsVzs9en3aerTg1wFelrPlzYtMdRTSvrEOtL+uxH/xM X-Received: by 2002:a05:6870:d7a1:b0:1b0:653a:af92 with SMTP id bd33-20020a056870d7a100b001b0653aaf92mr1253822oab.8.1691538388759; Tue, 08 Aug 2023 16:46:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691538388; cv=none; d=google.com; s=arc-20160816; b=fp0c/Ael3AVzc/X8vwoSdBsFx1eWHnVM02Nemvhs9XB6NUdI9kvX0EuFRh/bhad8wz OO9Lg4XAjhUlo56qXWvBMShe6bSe5z3wQrWyQ+3s3VY6Wn7i/Jc+yGgqZunzy/Zx/12P XZMY19ut2jn7I211hjFvQxfO/ctp1hFn4RBwz1fcyV2eyDVhvP2fs964oWWV6oc1keT8 2TrhjST/pNakvPaJpvmeux67xzEO7Ak8OIGzhB6Gn2gydalWvvYhED0hJpaDICnibYad eLysjxfpXUHzo+BDBGnswlZsPs3rnGR+HUxSjbwSE51zfd9fKxwLNPAribkiCRz2T9Hf ikgQ== 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 :dkim-signature; bh=HQgYw5lX3SkYq1STywg88ED6q5FjX9omCE5FKYEvLx8=; fh=h/qQBkFaKiogfCTyanXYN9NAO5ByXUFFi2AYXRuKhCY=; b=cvKwsukAPBuF4An+ChQaxdflbvGN5fjPmcdSYXd7+WGY6noJmjk+fqQcxeN7CQAtuX aIBZcSr7Lwk46YOZidwnPyZQZkHcagafSRcXzLAtFoz0UTu/82I7binACLS++t5O4/aQ vZe5je7zkv6lzvvi4M8Nk7nqYgCA6YEPpWnkRsuCH74mBUod9CW6Ot53QNFCUhgktmuX X9KapPgMbx0gOfOXgxJ6M/Q50hkbMfXFtOsjPfj8+1eSptlN8ugUvM/sST57aKwcqPKO Tq4brD2M72R+VktNYGWRr5EqV0YIRmLb4+R/qv/pY9aZrwNgV49OMAeZ44ZqfC3tvbei EpLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b="V2b/yZWh"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bs71-20020a63284a000000b0055bf3d0c987si7729555pgb.281.2023.08.08.16.46.16; Tue, 08 Aug 2023 16:46:28 -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; dkim=pass header.i=@linux.dev header.s=key1 header.b="V2b/yZWh"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231187AbjHHWel (ORCPT + 99 others); Tue, 8 Aug 2023 18:34:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230463AbjHHWeg (ORCPT ); Tue, 8 Aug 2023 18:34:36 -0400 Received: from out-106.mta1.migadu.com (out-106.mta1.migadu.com [IPv6:2001:41d0:203:375::6a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F5FA137 for ; Tue, 8 Aug 2023 15:34:34 -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=1691534073; 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: in-reply-to:in-reply-to:references:references; bh=HQgYw5lX3SkYq1STywg88ED6q5FjX9omCE5FKYEvLx8=; b=V2b/yZWh7iqOPKRM+woaS0Pcn2y/ZwlopGA/To5CR6hBItv7RHn++t0bdatVP+jBdJY3WF XEy5JoecUt0pwfcntmWSCZuzjtsjWYXbh4aYIVQPplR1enGjSuBkUvCm7NtvjmK/1e2a/q t2IOEGUJZhKpiH+y+nQ3gBn4OCPe5HA= From: Sui Jingfeng To: Bjorn Helgaas Cc: Dave Airlie , Daniel Vetter , linux-pci@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Sui Jingfeng Subject: [PATCH v2 05/11] PCI/VGA: Move the new_state assignment out of the loop Date: Wed, 9 Aug 2023 06:34:06 +0800 Message-Id: <20230808223412.1743176-6-sui.jingfeng@linux.dev> In-Reply-To: <20230808223412.1743176-1-sui.jingfeng@linux.dev> References: <20230808223412.1743176-1-sui.jingfeng@linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED 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 From: Sui Jingfeng In the vga_arbiter_notify_clients() function, the value of the 'new_state' variable will be 'false' on systems that have more than one VGA device. The value will be 'true' if there is only one VGA device or no VGA device at all. Hence, its value is not relevant to the iteration of the loop. So move the assignment clause out of the loop. For a system with multiple video cards, this patch saves unnecessary assignment. 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 dc10a262fb5e..6883067a802a 100644 --- a/drivers/pci/vgaarb.c +++ b/drivers/pci/vgaarb.c @@ -1468,22 +1468,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.34.1