Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2196620iof; Tue, 7 Jun 2022 22:54:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxn7KNLiG03PbGyq99gUfxhp/QBEiKeR8PlBIUjplXhpllZugIfPy/7O8d+OWqWcj4Jue24 X-Received: by 2002:a17:902:6907:b0:167:7ae6:a20a with SMTP id j7-20020a170902690700b001677ae6a20amr14599323plk.65.1654667677525; Tue, 07 Jun 2022 22:54:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654667677; cv=none; d=google.com; s=arc-20160816; b=hrMwcdfhhsS0Pybk/Q7EzZi+bs8AvAyQH6jw+TEwRP4oXPqds0gRoAuDwB4q/Gk02E mJpUZAK6r91JGsz5RlemtSEoNY0srBNPcTORdZBEWbrNumXuw28hJyEHTBydXQBOud64 +lt1Znu0xThnhvHjlWQ64iTpGeUQU5qJAtgWIeLF3D7XdTeQAhBxzfJQ+WYvL21SFejK DgONZHXyLHAYMUgN+28jrWcURBUsRO5nB8ifNWAdpYg+3stU4W+x4fMM6W0NZlqkY9mj eWVTLtGsvxEugUVCP61zggqbYYYTtruYLKqX0kXUcGHtyyxBnrE3V8WL1gMg5cusLeOT X0kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=oTlAYrQdFp9WiWzG2eozaHuZJCxuoVFuioeFhVzBwxI=; b=Qyn5XhTMHrDHELDdjZhP3usSCq2eokH/Tx0lJWNPNkiNUp/jkjzxieoT9dzG9OiGqc m4ChKTKQ8PnVSW8ZPhC73IoWM13G6o2H9Kzdj538G1XQSbb+KnNwFu5BiwcI/syqGp7s rETRCxh10ef5BwTiyCcyyKmKS/dfsceQ2iPGVTUogDIoc44N6FZxG9zpdwyQfjM9M7Ti oX9VYSwVes4Y0UzdDsMUfbqkw8sN0BfJApTFJpb2+JkMkFMGhu8Oat/YCHMSCMlrLikT 69eLSdtEXzLt3djWIfS6qGKKxbF/8epRzS2fciSVv3tmeo8UEVPq6n3LbIiUho4EAaYp 1Rvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zQsVyM6U; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id r22-20020a63ec56000000b003fc4001a30asi26380893pgj.544.2022.06.07.22.54.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:54:37 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zQsVyM6U; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7ED18149D8E; Tue, 7 Jun 2022 22:21:07 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350344AbiFHA4P (ORCPT + 99 others); Tue, 7 Jun 2022 20:56:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379276AbiFGWG4 (ORCPT ); Tue, 7 Jun 2022 18:06:56 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BB50252C3E; Tue, 7 Jun 2022 12:16:00 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C9A4B61846; Tue, 7 Jun 2022 19:15:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CFA9EC385A2; Tue, 7 Jun 2022 19:15:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654629359; bh=yUA+1PtCRM+RBKp1Y/Q9h+SLDKv6zQr75eH5WKIP9g4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zQsVyM6UZF5zOexMPX61cZR1cCa1eU3Ocn91wzS6eNOAcMMT9XGkHHU+sviL6ODGO 949vCKN48PDhB4SfX/V5zoZn1bfrCXZMxio+JWYQnDfZo0QfRG1PFUSB/ckSUMlS2g mkU0VCaOg52ESE3SbWtRC26llQE32pkCo78QXBpY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christoph Hellwig , Mario Limonciello , Robin Murphy , Christoph Hellwig , Joerg Roedel , Sasha Levin Subject: [PATCH 5.18 662/879] iommu/amd: Enable swiotlb in all cases Date: Tue, 7 Jun 2022 19:03:00 +0200 Message-Id: <20220607165022.062346337@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mario Limonciello [ Upstream commit 121660bba631104154b7c15e88f208c48c8c3297 ] Previously the AMD IOMMU would only enable SWIOTLB in certain circumstances: * IOMMU in passthrough mode * SME enabled This logic however doesn't work when an untrusted device is plugged in that doesn't do page aligned DMA transactions. The expectation is that a bounce buffer is used for those transactions. This fails like this: swiotlb buffer is full (sz: 4096 bytes), total 0 (slots), used 0 (slots) That happens because the bounce buffers have been allocated, followed by freed during startup but the bounce buffering code expects that all IOMMUs have left it enabled. Remove the criteria to set up bounce buffers on AMD systems to ensure they're always available for supporting untrusted devices. Fixes: 82612d66d51d ("iommu: Allow the dma-iommu api to use bounce buffers") Suggested-by: Christoph Hellwig Signed-off-by: Mario Limonciello Reviewed-by: Robin Murphy Reviewed-by: Christoph Hellwig Link: https://lore.kernel.org/r/20220404204723.9767-2-mario.limonciello@amd.com Signed-off-by: Joerg Roedel Signed-off-by: Sasha Levin --- drivers/iommu/amd/iommu.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c index a1ada7bff44e..079694f894b8 100644 --- a/drivers/iommu/amd/iommu.c +++ b/drivers/iommu/amd/iommu.c @@ -1838,17 +1838,10 @@ void amd_iommu_domain_update(struct protection_domain *domain) amd_iommu_domain_flush_complete(domain); } -static void __init amd_iommu_init_dma_ops(void) -{ - swiotlb = (iommu_default_passthrough() || sme_me_mask) ? 1 : 0; -} - int __init amd_iommu_init_api(void) { int err; - amd_iommu_init_dma_ops(); - err = bus_set_iommu(&pci_bus_type, &amd_iommu_ops); if (err) return err; -- 2.35.1