Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp259221pxb; Wed, 8 Sep 2021 23:43:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyOne/iOKbUcY3zdtmhaF/KrygnaELuzApqDsYEXnQeEihozaRaOm5GfAKQ/zDpQO3VxXiy X-Received: by 2002:a17:906:f289:: with SMTP id gu9mr1640909ejb.559.1631169830163; Wed, 08 Sep 2021 23:43:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631169830; cv=none; d=google.com; s=arc-20160816; b=pJgnrIW8QPDfOyS9vjPob94LyJyIDh8J+/O4yIMGYSLkwmumNMaz4XGQhLZ/ZaG+xF jSoeovtLejzO9+8AkKq4s+SNr+LyCaPCySDa/BB8/mdQisK7vj2xosck755x5f8Z4wIz GuZROjB15eNphgBbLdaWoIcEMsynFaihcc1S7e7tCWdFBhTtD7I3zaeUWSBbBo/xtH+u 7fd0isifKvEjuzWB+Zniarxg5E2gpzQmKz4K1x+Zto3c97NgBUt6W5tFNH1Khewhsptg SF8neefGUSbNNeBF5f71K11Sml1Nm5yV/K1o2GPIgA5tg8YKQR37N2+G2/rEmZK+5DDH J7sA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=akLaMR2Qq8amUpvssgxVNr2WG7Nl5vSl23ypQFllRfM=; b=kPG8ILGF4KHDUTa4iaCuywU9jpx/mlc9wrIEtKHbyMuAowXt/1AdR8UXrVnqg8RniA H41G4c1brpDYXhoNtuvvGMeJzl/NaQ8Ppv9fPFaqoKE8ymHQzKjbwrvLGRoQNRjH8ZjV c9fpDfj7EWepT1RAf0Q/9YknXzp1c24SIJn3quq5SwY/+G3HGCG9pK5prwPeT+TSuiG0 2MMUNFntE93/6iFEJ4JaopVtNA5g/biOqpjVWLEJVJd6OKhhdzS5xyxK+pTARfKZRs29 X7/h5/Xa83lEJQJ9osQRoIViLZFpD+eUvFDPecuTyg+U7B0EkRU5UQT4EjI34B0y70gD IjCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=QlU56PXY; 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=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id og48si314670ejc.686.2021.09.08.23.43.26; Wed, 08 Sep 2021 23:43:50 -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; dkim=pass header.i=@canonical.com header.s=20210705 header.b=QlU56PXY; 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=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235026AbhIIGhw (ORCPT + 99 others); Thu, 9 Sep 2021 02:37:52 -0400 Received: from smtp-relay-internal-0.canonical.com ([185.125.188.122]:50520 "EHLO smtp-relay-internal-0.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230433AbhIIGhv (ORCPT ); Thu, 9 Sep 2021 02:37:51 -0400 Received: from mail-ot1-f69.google.com (mail-ot1-f69.google.com [209.85.210.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id A99B53F320 for ; Thu, 9 Sep 2021 06:36:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1631169395; bh=akLaMR2Qq8amUpvssgxVNr2WG7Nl5vSl23ypQFllRfM=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=QlU56PXYiwED1TkFBvvem8n0nH/6c1M5r9bsHCB1gPMvaS6ZLfJxH7rQzCg5nom0p cCh8FAOHwKZgE0Di4XZeucjGOhfqvOos8dR3UnG2EgVXfmMh6ygyIc0d4Kxl/570K/ 3ij0ZXYzETsQ8AKcbKPxOXwmSwoB8BbsAjQ8iwJH/UokzEY1tOn+oGUQolCAsNYUC5 HkibcGicglR7pHUN13dzbwgb9fIWEEj1yiWUY1pPfRjztGAlGXmljPHFyvaz1j+rVQ eWQ7M1y0YfrqqieNAP7YU+lWH/mZN/XvYuqgtqq0V1dlzz5p6byM8MWlQH/N2+2evw vdGF6PIO3T5nA== Received: by mail-ot1-f69.google.com with SMTP id b25-20020a9d60d9000000b00519be3bdc04so552599otk.7 for ; Wed, 08 Sep 2021 23:36:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=akLaMR2Qq8amUpvssgxVNr2WG7Nl5vSl23ypQFllRfM=; b=w3/q0BnVEapznBzUtxLVoplas5gAgUpoBCqff310BFSNx3Odc0aPhdb9iy6EvH2wuA WGcEhtNFUEFXPA9F+LfXJZHTI0NWUPjOd5L9i/UVidzTwJFUjLYKvyaJe5sABn09uULk 1Rm5aph7IdnBDfDfFJHrAF8s07k2WSduI01Dy1ogUrQ4Q7EdFRP9EA1sRm2HWsiRt07F s3Mzaa0pGWPXyJWtds6a9deuCcr+mkbn+vl9l5OdTUQUfwBy5L3Bvef69ATEnjAVm8Aq u/gcHu+xUWueBtQ3DJKFqtDLohEXUSfAeIzEKNRqrg5OetN8yS8u4OOxbHCphLvRSLN9 78vA== X-Gm-Message-State: AOAM53007Xu7UdkFWomV/iQdMgbxfMKLX0EmD5fmqXn/G2cmSO1n7F2Z gydggZzaAqO2eIaQNHcJq9WUsTL2yGi5WrlhkmPlROgXLNRcnRbi622fN/Arw1LovnEL31wf3nE brSUCLSF8ZDTaMHR/nNBXrBVYeLy4+N4yy2WhCjaI8vP4zrs3HzRDXuFCWw== X-Received: by 2002:a05:6830:1355:: with SMTP id r21mr1140775otq.11.1631169187448; Wed, 08 Sep 2021 23:33:07 -0700 (PDT) X-Received: by 2002:a05:6830:1355:: with SMTP id r21mr1140764otq.11.1631169187145; Wed, 08 Sep 2021 23:33:07 -0700 (PDT) MIME-Version: 1.0 References: <20210708074232.924844-1-kai.heng.feng@canonical.com> In-Reply-To: From: Kai-Heng Feng Date: Thu, 9 Sep 2021 14:32:55 +0800 Message-ID: Subject: Re: [PATCH] iommu/amd: Enable swiotlb if any device supports iommu v2 and uses identity mapping To: Joerg Roedel Cc: Konrad Rzeszutek Wilk , Robin Murphy , will@kernel.org, "open list:AMD IOMMU (AMD-VI)" , open list Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 14, 2021 at 6:25 PM Joerg Roedel wrote: > > 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. I am currently working on this but I found that 4MB is not enough, 16MB is the minimal size to make the device work. How do I know the right SWIOTLB size for each device? > > (A boot option to always keep the aperture around might also be helpful > for some setups) OK, will also implement this in next iteration. Kai-Heng > > Regards, > > Joerg