From nobody Sat May 4 18:09:39 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1559083770; cv=none; d=zoho.com; s=zohoarc; b=nv3w3YgLwv5GUhULSAnkk4DpJ2K6QNFJFv2xMsFlThiDBkZ7cwJmEmsEQglA+Nm4EcT1jJ3Xw72Cbg/hb+aNSi/T5OLrzplyCLqMA00oxFGn9tT9fl88X8XcuXLTHQFwYNk0nHoORH7sd40N6Ysb9k4O9+ooFa+7ETs6CUYXAog= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559083770; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=qJlwbQK7A058JYVpfgej/PM6mCNhfsttq5GbpmAg5NY=; b=TEN4TUNEchTXKcUyJbulOSFrN8y/3MYaYmn9K7UR2krmaDCmnmES6h4im3gOKBuasFB/6OaVNXKpa95MtJ2k6OXdz97zklXmvvDwdNby+mspNH41oXUuAMTtM/YQrUzPK6ubZS+gNgBFBVBrQzRWWNugQgzA7CF0B9rCShDZrY8= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1559083770993749.3343872115092; Tue, 28 May 2019 15:49:30 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hVktO-0006WA-36; Tue, 28 May 2019 22:48:26 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hVktM-0006VL-HW for xen-devel@lists.xenproject.org; Tue, 28 May 2019 22:48:24 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id b2d5a4b2-819a-11e9-ae8f-57a10ded9d94; Tue, 28 May 2019 22:48:24 +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 2F11920B1F; Tue, 28 May 2019 22:48:23 +0000 (UTC) X-Inumbo-ID: b2d5a4b2-819a-11e9-ae8f-57a10ded9d94 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559083703; bh=1lcuTO8r4FjCrgtzeV5AH8J5IwwIPxaTPIFzkL9GMxA=; h=Date:From:To:cc:Subject:From; b=15iL24htgosGHPqxQAvYN8aXa9nj2MZgJZPyO5POq+C6+DMGBs9xt0KKqj54QafUe Da16Ts8r5nt0nCZEDYzkqBeMQVTycFAa3Ctky72h4+SPj++G+VAqTox5G3j0toFwZv rGHZn42qcgxCXxHKyw8QHHgOraLDEyU4Tk6n2qdA= Date: Tue, 28 May 2019 15:48:22 -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 v2] 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Stefano Stabellini On arm64 swiotlb is often (not always) already initialized by mem_init. We don't want to initialize it twice, which would trigger a second memory allocation. Moreover, the second memory pool is typically made of high pages and ends up replacing the original memory pool of low pages. As a side effect of this change, it is possible to have low pages in swiotlb-xen on arm64. Signed-off-by: Stefano Stabellini Reviewed-by: Boris Ostrovsky --- Changes in v2: - improve commit message - don't add nested ifs diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c index 877baf2..8a3cdd1 100644 --- a/drivers/xen/swiotlb-xen.c +++ b/drivers/xen/swiotlb-xen.c @@ -211,6 +211,15 @@ int __ref xen_swiotlb_init(int verbose, bool early) retry: bytes =3D xen_set_nslabs(xen_io_tlb_nslabs); order =3D get_order(xen_io_tlb_nslabs << IO_TLB_SHIFT); + + /* + * IO TLB memory already allocated. Just use it. + */ + if (io_tlb_start !=3D 0) { + xen_io_tlb_start =3D phys_to_virt(io_tlb_start); + goto end; + } + /* * Get IO TLB memory from any location. */ @@ -240,7 +249,6 @@ int __ref xen_swiotlb_init(int verbose, bool early) m_ret =3D XEN_SWIOTLB_ENOMEM; goto error; } - xen_io_tlb_end =3D xen_io_tlb_start + bytes; /* * And replace that memory with pages under 4GB. */ @@ -267,6 +275,8 @@ int __ref xen_swiotlb_init(int verbose, bool early) } else rc =3D swiotlb_late_init_with_tbl(xen_io_tlb_start, xen_io_tlb_nslabs); =20 +end: + xen_io_tlb_end =3D xen_io_tlb_start + bytes; if (!rc) swiotlb_set_max_segment(PAGE_SIZE); =20 --=20 2.7.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel