Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp263314pxv; Wed, 14 Jul 2021 03:28:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJybrjMCAlVeFljoNWIY4Y7mG4G/QKUaINdfzyAs80ZyQq/F7AXJAqAIfueE+/Yi3UxLXj8k X-Received: by 2002:a17:907:9602:: with SMTP id gb2mr11687857ejc.354.1626258503213; Wed, 14 Jul 2021 03:28:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626258503; cv=none; d=google.com; s=arc-20160816; b=rl3un9FtgD0wdn3V2cPIOLN3oeiGrepZVSL/mevpoKKMtEewYVsg9MazbzMycha0ON ssqcGd0R/Os6BP0rqI9h57+7KKEO9Zm23hd9c/IpL4kHImrOutE8cl/ECXDHgGuMcqcK 7vM+O/+QDJK/OoYiNaDidGo8YZrKOAIKvvcMMclpH+GZcCXb0Yn49pCtB7wIZFa4Ogt7 qZtgFu/M/gYeosqt+U/dCh1PR20oPRprh0ZCTm5a0cvI3cIxje520N9AaUdQbbS6qw/j eQUqcgR6WgVbGWD/1rp6U2VxtLbFfUA32g8Bn2C4BESbfHfVjD/havL/FfIVpGETjlkK 3yxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=svbWJRxeAWI08ypY9lbLo/mZkPJ1d4jUMBbuBNr4OWQ=; b=m5i4IU17vqE7/PqVO53GXTVt5RCnwIlEd9AMWoFNRR9+65/A2Q9JdBM/v8l6qc9vZf +8ic0+PGBq+3UzP+IY8NngiTfEohphqjJN+wRDp0xi2qAJAKHq/UBGITWsDZwUBPW3Kj WMMF5pr9zzzyJRhRzEGWJ2j+STYBCltOwfatU7oEYQ4gOGCwRipnWmwcjLB7E4HK5YMn 2pGDSXE16GGxKxf5+vgnuATuZCpthRzTpQIzzkrnNCQrSIOdVoV2GGi2SQwV9QBLIBYK smrqgAO8yM/Qbvdw58C8Y2f7EH6w21+304i++aGBKUO83iLZ6PTAYIiKh6SXFTK6DieJ +gUw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h24si2612479ejt.474.2021.07.14.03.27.59; Wed, 14 Jul 2021 03:28:23 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238921AbhGNK2o (ORCPT + 99 others); Wed, 14 Jul 2021 06:28:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238728AbhGNK2o (ORCPT ); Wed, 14 Jul 2021 06:28:44 -0400 Received: from theia.8bytes.org (8bytes.org [IPv6:2a01:238:4383:600:38bc:a715:4b6d:a889]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3E7CC06175F for ; Wed, 14 Jul 2021 03:25:52 -0700 (PDT) Received: by theia.8bytes.org (Postfix, from userid 1000) id 7006E3D0; Wed, 14 Jul 2021 12:25:47 +0200 (CEST) Date: Wed, 14 Jul 2021 12:25:31 +0200 From: Joerg Roedel To: Konrad Rzeszutek Wilk Cc: Robin Murphy , Kai-Heng Feng , will@kernel.org, "open list:AMD IOMMU (AMD-VI)" , open list Subject: Re: [PATCH] iommu/amd: Enable swiotlb if any device supports iommu v2 and uses identity mapping Message-ID: References: <20210708074232.924844-1-kai.heng.feng@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 13, 2021 at 07:57:40PM -0400, Konrad Rzeszutek Wilk wrote: > The SWIOTLB does have support to do late initialization (xen-pcifront > does that for example - so if you add devices that can't do 64-bit it > will allocate something like 4MB). That sounds like a way to evaluate. I suggest to allocate the SWIOTLB memory at boot and when the IOMMUs are initialized we re-evaluate what we ended up with and free the SWIOTLB memory if its not needed. If that turns out to be wrong during runtime (e.g. because a device is switched to a passthrough default domain at runtime), we allocate a small aperture for this device like the above mentioned 4MB. (A boot option to always keep the aperture around might also be helpful for some setups) Regards, Joerg