From mboxrd@z Thu Jan 1 00:00:00 1970 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EA331C433EF for ; Mon, 4 Oct 2021 14:17:23 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8345F61215 for ; Mon, 4 Oct 2021 14:17:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8345F61215 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.201509.356059 (Exim 4.92) (envelope-from ) id 1mXOmG-0005ZI-Rw; Mon, 04 Oct 2021 14:17:12 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 201509.356059; Mon, 04 Oct 2021 14:17:12 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mXOmG-0005ZB-P2; Mon, 04 Oct 2021 14:17:12 +0000 Received: by outflank-mailman (input) for mailman id 201509; Mon, 04 Oct 2021 14:17:11 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mXOiP-0008QG-F1 for xen-devel@lists.xenproject.org; Mon, 04 Oct 2021 14:13:13 +0000 Received: from mail-lf1-x12f.google.com (unknown [2a00:1450:4864:20::12f]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id e6cbbff4-ca33-483a-85a9-6b924cb03d70; Mon, 04 Oct 2021 14:12:17 +0000 (UTC) Received: by mail-lf1-x12f.google.com with SMTP id m3so71516962lfu.2 for ; Mon, 04 Oct 2021 07:12:17 -0700 (PDT) Received: from localhost.localdomain (host-176-36-245-220.b024.la.net.ua. [176.36.245.220]) by smtp.gmail.com with ESMTPSA id n12sm1076809lfe.145.2021.10.04.07.12.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Oct 2021 07:12:08 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: e6cbbff4-ca33-483a-85a9-6b924cb03d70 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Mt9OWBAhbT//DIBCaDBPG1KX4to8WfBEU/gi6Ti13xs=; b=Zo/VaiBmlmMtZhzxzoT0AEknQqXI/pGqOzRD37w9kRaNWip0ilJ9I+DTC3inQe6gVQ ydV9F4HqQ30/x1fOg98A3JjKM2O7FrIkUAeD0wv5cZMB/ImlkT+BAuVcfbhCWxl2DFAY HxBGYFA2Qn7ny2406U5W8QCXYG/Shb4sBOY1NB/7pEYErmiOf8F63oJ2QdUJTGGcaDam tEEIvpAZrj3RSEnuuqJuiyECYW0wKCvtxOcFj8dt7vMkPGPWp4uI91oB3PDW0TwvkD8x fMcLaTDHUaFOT+zEjPEa4d9OZZ7HmD/VlTn4vRmYfwOqH2iA52GAsuRGi1iu/m182ufW EASA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Mt9OWBAhbT//DIBCaDBPG1KX4to8WfBEU/gi6Ti13xs=; b=PyLJwHno8xFfiRGzx+Z/ZDFc6oRzLDEdHMPuyl8ftnCMpLrELoQvuWIA0A+NWwb8gV 1Y0etFCsTV1iGCcJpQ3UqveTpiCCNHtjoY3vM3Vri+GeAXdSinkwf/et/cM7v0hqLsym 4QiDpBdPSt/M1nVMm6IBWZfJkCSTvDb5/+BDgu9jOGzXi/TzR0rvsNzweSCSsHbOIemB dpL/cIQZWV5AZEv8ORZxqqY3N2q+G+fadR3UYeOqZJnZqXExW0U6GBogVxknIEDF6RGB h5oLPhNSk3LzjdNM1W0L9OizOJgAPdlzeLN8RuNKeDE4h3qk/oNfRpcwDDvLMiL9R52h xOag== X-Gm-Message-State: AOAM53095FaXYS/wQR5EUVDu5dSqB6jAbajQGQx36EaPNg5y50ZdAeVy F0lzb3SPjm92sSs56rQO6Si/IXOIBBrlOA== X-Google-Smtp-Source: ABdhPJzVgJE4NpanPPuA1m9xh0vQ+K01UWveq9p7UsP19uF85d6cp+WkxfT9exshD+EyIpsPzcM74A== X-Received: by 2002:ac2:5c51:: with SMTP id s17mr7230247lfp.32.1633356728996; Mon, 04 Oct 2021 07:12:08 -0700 (PDT) From: Oleksandr Andrushchenko To: xen-devel@lists.xenproject.org Cc: julien@xen.org, sstabellini@kernel.org, oleksandr_tyshchenko@epam.com, volodymyr_babchuk@epam.com, Artem_Mygaiev@epam.com, roger.pau@citrix.com, jbeulich@suse.com, andrew.cooper3@citrix.com, george.dunlap@citrix.com, paul@xen.org, bertrand.marquis@arm.com, rahul.singh@arm.com, Oleksandr Andrushchenko Subject: [PATCH v4 11/11] xen/arm: Process pending vPCI map/unmap operations Date: Mon, 4 Oct 2021 17:11:51 +0300 Message-Id: <20211004141151.132231-12-andr2000@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211004141151.132231-1-andr2000@gmail.com> References: <20211004141151.132231-1-andr2000@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Oleksandr Andrushchenko vPCI may map and unmap PCI device memory (BARs) being passed through which may take a lot of time. For this those operations may be deferred to be performed later, so that they can be safely preempted. Currently this deferred processing is happening in common IOREQ code which doesn't seem to be the right place for x86 and is even more doubtful because IOREQ may not be enabled for Arm at all. So, for Arm the pending vPCI work may have no chance to be executed if the processing is left as is in the common IOREQ code only. For that reason make vPCI processing happen in arch specific code. Please be aware that there are a few outstanding TODOs affecting this code path, see xen/drivers/vpci/header.c:map_range and xen/drivers/vpci/header.c:vpci_process_pending. Cc: Andrew Cooper Cc: Paul Durrant Signed-off-by: Oleksandr Andrushchenko [x86 changes] Acked-by: Jan Beulich Reviewed-by: Stefano Stabellini --- Since v2: - update commit message with more insight on x86, IOREQ and Arm - restored order of invocation for IOREQ and vPCI processing (Jan) Since v1: - Moved the check for pending vpci work from the common IOREQ code to hvm_do_resume on x86 - Re-worked the code for Arm to ensure we don't miss pending vPCI work --- xen/arch/arm/traps.c | 13 +++++++++++++ xen/arch/x86/hvm/hvm.c | 6 ++++++ xen/common/ioreq.c | 9 --------- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index 219ab3c3fbde..b246f51086e3 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -2304,6 +2305,18 @@ static bool check_for_vcpu_work(void) } #endif + if ( has_vpci(v->domain) ) + { + bool pending; + + local_irq_enable(); + pending = vpci_process_pending(v); + local_irq_disable(); + + if ( pending ) + return true; + } + if ( likely(!v->arch.need_flush_to_ram) ) return false; diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index aa418a3ca1b7..c491242e4b8b 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -546,6 +546,12 @@ void hvm_do_resume(struct vcpu *v) pt_restore_timer(v); + if ( has_vpci(v->domain) && vpci_process_pending(v) ) + { + raise_softirq(SCHEDULE_SOFTIRQ); + return; + } + if ( !vcpu_ioreq_handle_completion(v) ) return; diff --git a/xen/common/ioreq.c b/xen/common/ioreq.c index d732dc045df9..689d256544c8 100644 --- a/xen/common/ioreq.c +++ b/xen/common/ioreq.c @@ -25,9 +25,7 @@ #include #include #include -#include #include -#include #include #include @@ -212,19 +210,12 @@ static bool wait_for_io(struct ioreq_vcpu *sv, ioreq_t *p) bool vcpu_ioreq_handle_completion(struct vcpu *v) { - struct domain *d = v->domain; struct vcpu_io *vio = &v->io; struct ioreq_server *s; struct ioreq_vcpu *sv; enum vio_completion completion; bool res = true; - if ( has_vpci(d) && vpci_process_pending(v) ) - { - raise_softirq(SCHEDULE_SOFTIRQ); - return false; - } - while ( (sv = get_pending_vcpu(v, &s)) != NULL ) if ( !wait_for_io(sv, get_ioreq(s, v)) ) return false; -- 2.25.1