Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp1719098pxy; Sun, 2 May 2021 00:09:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyeeu5iqRJiUcbXzKgQNS6OepMoBxkZ5FfwYINMZ0UTRvGd/+APVL7EnYhje99VddlqfocG X-Received: by 2002:a17:902:ee11:b029:ed:7108:623e with SMTP id z17-20020a170902ee11b02900ed7108623emr14521395plb.38.1619939389560; Sun, 02 May 2021 00:09:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619939389; cv=none; d=google.com; s=arc-20160816; b=BdULfeRuKgw9J5y0khOs4w++KCtyNqjyJGeIVIYvpkdxdW+Jz8VQ+eNFwn43eimHtQ JMJkSGieE7zl7cO/loBxtE7xRz8p0vmMgmpOL8enXxA4H+iD64VJyHjQ1YxCOs9UPljF 5bfj2jmw+cd5ti74qBJKAuJRZna1e6bONUkLiQGVGLQJkRWPLLr/CC65BUhUb4ccYl2y Yh1BnRcNZkXp9fWuzD3O3C87EUqOqh1qlWPnDZvGNDY4QHV0djrEdp8IZkUJoeWHZbH9 hwgt03FnQbPglRj3gh7JZOBZzg3eKfeXx/mRJk+Aj1yrgmNRJoKTbTcGykYXIPI4+gfu 6RYg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5X0JTQzlcxqdyb4573dS6/kX2Ui7vOskaKMybRf6Z5M=; b=ca85rIkeOKMPXFsR7GI0k9VXORhVrWYyj/jj+J1gGfK1YdxXW5RMw9jBQtgM/ZEacl AN+pbdVc4l4u6uPe9IyQt4iCYLztNUL+VcWvN9jEapxZO2EAbLApj1cF0TeEuFPYofRi fJUX+nQBHVrQAQqxATJCX0AtYtKUbipdw3kAW4+PT2y3kbyh9xgOvT1KybTYAwOqZRsZ Ub2o2yB0DSMttJ9NdarAJDF+NPSUYdgVO3E/GEgevvW/I6K8lRbeirzrHpwDTckVACUp APBBsyYiKpvtchIngGmr3mpbRosOrNnRveho9sjVi3zLnD8xS5LQ6PUJcWZmmdeN5/BY dzxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="HZVuO6/R"; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o34si12366074pgm.247.2021.05.02.00.09.37; Sun, 02 May 2021 00:09:49 -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=@gmail.com header.s=20161025 header.b="HZVuO6/R"; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231303AbhEBHGI (ORCPT + 99 others); Sun, 2 May 2021 03:06:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230120AbhEBHGG (ORCPT ); Sun, 2 May 2021 03:06:06 -0400 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B34BC06174A for ; Sun, 2 May 2021 00:05:15 -0700 (PDT) Received: by mail-pl1-x62d.google.com with SMTP id t4so393447plc.6 for ; Sun, 02 May 2021 00:05:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5X0JTQzlcxqdyb4573dS6/kX2Ui7vOskaKMybRf6Z5M=; b=HZVuO6/Rey41sy8z0pQayPzweV8rnRftn35sAiSoX5e1Kkqh46ZUmwXTz5crnp5MDD KqRPfVQo+19EYhm93km29tf3f3RkxPcBy5WTshI1nUf1OXz8DGqbuH3QughkiO5ww0YJ 09cV7VS/gPCuKq7997LUBtf830okwiYk8vfPczoCIMUlrdWD2uFwL2DP/Nsq+XYnAock JbUm9G6T6w4Ml7jiMAwR9lcVCEg/QhxtK3UVycjLmRYqXSneZgmeTMsVUPlKHO8+N7Ur JT3fRPicXILbS8zocKyhYL8XhodzQeXgF/cAWu9y00beZ3WM0g/bbbRrU3l08MT+vdeY Zl+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5X0JTQzlcxqdyb4573dS6/kX2Ui7vOskaKMybRf6Z5M=; b=Th8EBZMJ0+ddBvcSKwYsanX9VrXFNO/dr92QiV6YEh/O/PWoZcDOYS+O3osleHjm0h J6ZZkLY/l8L6MV+iQHgA0Qi6MPF5sAoEjorSkJzPnAobpFo0JyqSSXtr90UJL5gQtFEE 39Ozil23x2nUmLiP3l2xm68nQBM2mF+seRCaiawu5jTofvD3c4MyldBBAeJec+DHFy3E 0P3DF84dsr4KPZdDbbCes0FogqWn+iqHtlQhj548AERSPAw9w3sLOSabNxfqEi942TVr ozrpBLJJUNlmC7lXA7D4X1cprXBka5Yiz6pRy4+wS39R2EH9PC8hYmb2K5vEc+6gN6AQ wBLg== X-Gm-Message-State: AOAM531u5qyQE2ffSZp5Vfo8dFRe7odIuNiykmaa8enM3hzQ4ZbMoYtC j06uGuETgaI3ViDJPN87ZGQ= X-Received: by 2002:a17:90a:a611:: with SMTP id c17mr10388845pjq.53.1619939114598; Sun, 02 May 2021 00:05:14 -0700 (PDT) Received: from sc2-haas01-esx0118.eng.vmware.com ([66.170.99.1]) by smtp.gmail.com with ESMTPSA id r18sm14345713pjo.30.2021.05.02.00.05.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 May 2021 00:05:14 -0700 (PDT) From: Nadav Amit X-Google-Original-From: Nadav Amit To: Joerg Roedel , Will Deacon Cc: Nadav Amit , Jiajun Cao , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/4] iommu/amd: Do not sync on page size changes Date: Sat, 1 May 2021 23:59:59 -0700 Message-Id: <20210502070001.1559127-5-namit@vmware.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210502070001.1559127-1-namit@vmware.com> References: <20210502070001.1559127-1-namit@vmware.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nadav Amit Some IOMMU architectures perform invalidations regardless of the page size. In such architectures there is no need to sync when the page size changes or to regard pgsize when making interim flush in iommu_iotlb_gather_add_page(). Add a "ignore_gather_pgsize" property for each IOMMU-ops to decide whether gather's pgsize is tracked and triggers a flush. Cc: Joerg Roedel Cc: Will Deacon Cc: Jiajun Cao Cc: iommu@lists.linux-foundation.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Nadav Amit --- drivers/iommu/amd/iommu.c | 1 + include/linux/iommu.h | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c index b8cabbbeed71..1849b53f2149 100644 --- a/drivers/iommu/amd/iommu.c +++ b/drivers/iommu/amd/iommu.c @@ -2215,6 +2215,7 @@ const struct iommu_ops amd_iommu_ops = { .put_resv_regions = generic_iommu_put_resv_regions, .is_attach_deferred = amd_iommu_is_attach_deferred, .pgsize_bitmap = AMD_IOMMU_PGSIZES, + .ignore_gather_pgsize = true, .flush_iotlb_all = amd_iommu_flush_iotlb_all, .iotlb_sync = amd_iommu_iotlb_sync, .def_domain_type = amd_iommu_def_domain_type, diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 32d448050bf7..1fb2695418e9 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -284,6 +284,7 @@ struct iommu_ops { int (*def_domain_type)(struct device *dev); unsigned long pgsize_bitmap; + bool ignore_gather_pgsize; struct module *owner; }; @@ -508,7 +509,7 @@ static inline void iommu_iotlb_gather_add_page(struct iommu_domain *domain, * a different granularity, then sync the TLB so that the gather * structure can be rewritten. */ - if (gather->pgsize != size || + if ((gather->pgsize != size && !domain->ops->ignore_gather_pgsize) || end + 1 < gather->start || start > gather->end + 1) { if (gather->pgsize) iommu_iotlb_sync(domain, gather); -- 2.25.1