From patchwork Wed May 22 23:26:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 10956789 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 495096C5 for ; Wed, 22 May 2019 23:28:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4DAF0204BA for ; Wed, 22 May 2019 23:28:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3C70E26E47; Wed, 22 May 2019 23:28:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D551D204BA for ; Wed, 22 May 2019 23:28:29 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hTacv-0004Ih-94; Wed, 22 May 2019 23:26:29 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hTacu-0004Ic-27 for xen-devel@lists.xenproject.org; Wed, 22 May 2019 23:26:28 +0000 X-Inumbo-ID: 04a8cb30-7ce9-11e9-8980-bc764e045a96 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 04a8cb30-7ce9-11e9-8980-bc764e045a96; Wed, 22 May 2019 23:26:26 +0000 (UTC) Received: from localhost (c-67-164-102-47.hsd1.ca.comcast.net [67.164.102.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3326B20881; Wed, 22 May 2019 23:26:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558567585; bh=wCdM3AvrhUhfJUpVQhYWXALTPt0dXlRc4Yx6aMltnxQ=; h=Date:From:To:cc:Subject:From; b=cAZP7Bc1ySrquQwX4HblyhPC73702bAiiesb0NNs8Rxs2VojqZV4/p82Llhu8aANJ fHFrCDfcrTxWF1wk4yhmUZ8YIV/9zRWA9mXy/IR8yU/Vxlz2lUGVkInZsQabaKNiE1 /NfZWfaaQqAmh811T36ESGoegvGAFSEXdLRgrt3Y= Date: Wed, 22 May 2019 16:26:24 -0700 (PDT) From: Stefano Stabellini X-X-Sender: sstabellini@sstabellini-ThinkPad-T480s To: konrad.wilk@oracle.com, boris.ostrovsky@oracle.com, jgross@suse.com Message-ID: User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Subject: [Xen-devel] [PATCH] xen/swiotlb: don't initialize swiotlb twice on arm64 X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: xen-devel@lists.xenproject.org, Julien.Grall@arm.com, sstabellini@kernel.org Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Stefano Stabellini On arm64 swiotlb is already initialized by mem_init. We don't want to initialize it twice, the memory is already allocated. Detect this condition in swiotlb-xen and skip the second initialization. Signed-off-by: Stefano Stabellini --- There are other issues which I found recently affecting the swiotlb on arm64 -- I'll send the other patches separately. diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c index 877baf2..8fcda2bf4 100644 --- a/drivers/xen/swiotlb-xen.c +++ b/drivers/xen/swiotlb-xen.c @@ -206,6 +206,7 @@ int __ref xen_swiotlb_init(int verbose, bool early) int rc = -ENOMEM; enum xen_swiotlb_err m_ret = XEN_SWIOTLB_UNKNOWN; unsigned int repeat = 3; + bool pre_initialized = false; xen_io_tlb_nslabs = swiotlb_nr_tbl(); retry: @@ -214,7 +215,10 @@ int __ref xen_swiotlb_init(int verbose, bool early) /* * Get IO TLB memory from any location. */ - if (early) { + if (io_tlb_start != 0) { + xen_io_tlb_start = phys_to_virt(io_tlb_start); + pre_initialized = true; + } else if (early) { xen_io_tlb_start = memblock_alloc(PAGE_ALIGN(bytes), PAGE_SIZE); if (!xen_io_tlb_start) @@ -264,7 +268,7 @@ int __ref xen_swiotlb_init(int verbose, bool early) verbose)) panic("Cannot allocate SWIOTLB buffer"); rc = 0; - } else + } else if (!pre_initialized) rc = swiotlb_late_init_with_tbl(xen_io_tlb_start, xen_io_tlb_nslabs); if (!rc)