Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2876737pxk; Sun, 20 Sep 2020 21:54:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQJrT7X7816MMr/i0I4BafMRTHV0/7Oeu33PpR/lVIy8xP7NY2WbtXaKlJC1aes1rAuycj X-Received: by 2002:aa7:cd85:: with SMTP id x5mr21933791edv.0.1600664042117; Sun, 20 Sep 2020 21:54:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600664042; cv=none; d=google.com; s=arc-20160816; b=OxtrZhNsSdsPVdDMuG7i5pZSQwUl82uwm0zKn7MEr8Sqs9ZsJ7jTQWlM79jkqDmMfg HpnMa24ck+QyBDpzpyJEWCffcfAhXiYXxGd2J2PMa5VyPJc1teOBoqzpBtLfhDArYOoq ucqzgfYaPSVETMuYbRsxPFERdE2DiZgEsdcrmoqFzCGxs7qnfK8DP9ly+96LkDmT3kX2 RCLFRTGvDxNY+ZMuGG4y7RMcYAvtVl9zsSQXBOdxwptsqYbmbVBQMNODJ2vwX2rnKuhs 36L+G3Whsl9RRl+iqS1W3VxTrKUqbQ1ngtiV7Ek+2KYqc0P4AL7WhnuUf7jIE7bHhiuz /QfQ== 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; bh=xjGTYWmkLG5MT6H+G/x0uNNzmgYkJxdlOeccW1SD1ZU=; b=ojl3VtOHurm529A3qexC+E7q5IYJyN5qXPfl3QtTA/fPG6mSkRiQRgdQZ3EjALE2Xh ZPH2Wk1Bq8iy3bMf2SJQ6BhFbed+M4gquHNTwZRO88egF9ZmotLSFk2p4E87WFr/rc0r q5gKzAPXNROMlZjul56OV+QJvHUU8gvUJlYQiqrodia9HsnYiEA8qzjaPqwKZGxmO1yG ovr/zhwukl/yQmr75O2I4EuG6R2Dqzz7otNyvjr1QA/KCR48aRBWGGD164YM7c5UOszY oeobMx6RLat/dIrtsycZsJHz1pfA9ten+d+AeWCMaorPSXzfQqBm57C3huYolGz/0j5C Rb8g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z15si8818020ejr.202.2020.09.20.21.53.37; Sun, 20 Sep 2020 21:54:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726366AbgIUEvk (ORCPT + 99 others); Mon, 21 Sep 2020 00:51:40 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:13736 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726011AbgIUEvk (ORCPT ); Mon, 21 Sep 2020 00:51:40 -0400 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id EBD527101C9BF283D53A; Mon, 21 Sep 2020 12:51:37 +0800 (CST) Received: from DESKTOP-8RFUVS3.china.huawei.com (10.174.185.226) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.487.0; Mon, 21 Sep 2020 12:51:29 +0800 From: Zenghui Yu To: , CC: , , , Zenghui Yu Subject: [PATCH v2 2/2] vfio/pci: Don't regenerate vconfig for all BARs if !bardirty Date: Mon, 21 Sep 2020 12:51:16 +0800 Message-ID: <20200921045116.258-2-yuzenghui@huawei.com> X-Mailer: git-send-email 2.23.0.windows.1 In-Reply-To: <20200921045116.258-1-yuzenghui@huawei.com> References: <20200921045116.258-1-yuzenghui@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.174.185.226] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now we regenerate vconfig for all the BARs via vfio_bar_fixup(), every time any offset of any of them are read. Though BARs aren't re-read regularly, the regeneration can be avoid if no BARs had been written since they were last read, in which case the vdev->bardirty is false. Let's predicate the vfio_bar_fixup() on the bardirty so that it can return immediately if !bardirty. Suggested-by: Alex Williamson Signed-off-by: Zenghui Yu --- * From v1: - Per Alex's suggestion, let vfio_bar_fixup() test vdev->bardirty to avoid doing work if bardirty is false, instead of removing it entirely. - Rewrite the commit message. drivers/vfio/pci/vfio_pci_config.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/vfio/pci/vfio_pci_config.c b/drivers/vfio/pci/vfio_pci_config.c index d98843feddce..5e02ba07e8e8 100644 --- a/drivers/vfio/pci/vfio_pci_config.c +++ b/drivers/vfio/pci/vfio_pci_config.c @@ -467,6 +467,9 @@ static void vfio_bar_fixup(struct vfio_pci_device *vdev) __le32 *vbar; u64 mask; + if (!vdev->bardirty) + return; + vbar = (__le32 *)&vdev->vconfig[PCI_BASE_ADDRESS_0]; for (i = 0; i < PCI_STD_NUM_BARS; i++, vbar++) { -- 2.19.1