Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp6089564yba; Thu, 11 Apr 2019 11:50:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqwTteoOrpeTQk4nu5NQ166d6ZwWYefGIjenrj8ooW7xpVrwDBxWlpNYS89f0HKtOhDjoNc0 X-Received: by 2002:a63:df12:: with SMTP id u18mr48962783pgg.135.1555008619404; Thu, 11 Apr 2019 11:50:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555008619; cv=none; d=google.com; s=arc-20160816; b=Zd9As8T7WXftqeAxu4I2E51qcfrA3i1OicHTkkzSkGe14HO7bFcLGY38ooFTpB+fMi o9Avk8UEnqGhiNOImcozhSFwtDZGjiP3F6V6r398lCQnlJZSwkKx/nQ05LQs/hKP4+BP iaICVo9ieIxbZAjY1AZUAJ2jCv12Djuhky3dF0/6NYWGiSfSenzZxehx3RbYVTHG96f6 GvutHXYpDcHJD/hM6bWZKWUPQZ3Ss38akYCfScMwVHJVOjbKA6Tdn305GI3H4Xk2FfNo ip3OoW5axbuSlQDUBD6YSdjTr4IYM57vVSytMx9nu0lyNo00ku07tU2VnC8yY02t0T2Y mxTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=0ptM0TW5MEf0wZjhcNVg+kVepdW4r8Z6tyROfJJShQo=; b=xR086+GCc8zj0TB9f99aUpptiY1LUW6TCDuRLjKcjZxGgv8qwh2UbT1EjEvCd6bRy3 LkJkfN7nwDRDlhjgIdKY3HTqVL2oXDx0ywdMNd/RrZxG1L2oI/couLVMT3f9DRsfjJAi 1Kt0UYhJGQGp2OJNiuDTLUby1yDeiSRGByZca+ZmvNfYIQdbhbTeDQUQeXTxx+cSog9i uu6Bm/nfGt2NaxO3bDgsV5UvfAUYApcHviY+shHpdpi8eIN+p1UgI7e3GRggbh9MuZD4 7QiU5ZX3xj9UroegJohWiU7v8ZCwa0Stp03Jkg+b5RG1cR8oxAUn8Enah7je8Xyb3c8O Qpew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arista.com header.s=googlenew header.b=Kz0209+s; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=REJECT dis=NONE) header.from=arista.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 24si34590056pfi.21.2019.04.11.11.50.03; Thu, 11 Apr 2019 11:50:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@arista.com header.s=googlenew header.b=Kz0209+s; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=REJECT dis=NONE) header.from=arista.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726924AbfDKStK (ORCPT + 99 others); Thu, 11 Apr 2019 14:49:10 -0400 Received: from mail-ed1-f65.google.com ([209.85.208.65]:44030 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726857AbfDKStI (ORCPT ); Thu, 11 Apr 2019 14:49:08 -0400 Received: by mail-ed1-f65.google.com with SMTP id w3so6123507edu.10 for ; Thu, 11 Apr 2019 11:49:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arista.com; s=googlenew; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0ptM0TW5MEf0wZjhcNVg+kVepdW4r8Z6tyROfJJShQo=; b=Kz0209+sKNZfmB0yWwNPjjrMA+GYb4rsz3YQ+7qzCBKV0K8VKU+rELf+Zl1rDwGfGG UDqhVf2LzXA6K1Mp+V7RE4dqFrJsHX5w+JbTNVOgDNMqnsvq1/Svzxa1O30Nwx4bNza7 xhOejAKAbe35ytPwR0TZVkNIacGaIechwtfh4zN2DCFIKQ4M9BguB3dgKppQ9rukI4fk jwu4Kh6E1Kp4KE4cvVyzWTm9dLB+7BauhZN2nsIMnKgsjVX0U/GpqN2Ak+4MJtwQ7Rct vag21Of0Bv8JJEz+PXrI7LQkFSMnYl4wWcIJZDQCt3rzHh/G7O3Wjvfv8J/dr1KSZ6iE ULLA== 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; bh=0ptM0TW5MEf0wZjhcNVg+kVepdW4r8Z6tyROfJJShQo=; b=QibtQlw7C4EfV36ZQooN+ANxCJVXXCH31fPF5dOpBQvZfJOmYtPtYuSY3FhkCVsxPb VUKhzvx1mecA/eCfewncxET3rAYWlZIcduiYmSDkttCUSjJw4FbB44tMKmczIaHPX5dX eiO0u5EMm/6IiGjL1QxOCUVGh3J1dSqanWP1ltoOUi5iGS9umk8K53uI8ObWy33cWzAQ 7ay33C1/FSyAI1k83XgxodAMjDA9L9j/jrQcQR+6M0x84VzAIEn0grI+1wXynAQzbCYd J68PBxzcVKSo/X7p24Ln6dj3zLvH9O0ci4iRHZkbbGXsugfIeRdH3OYVghLxy8n425lF Aidg== X-Gm-Message-State: APjAAAXipFlZCV2wCLY/u5WSCZ+aKuVEk5iiBDlqXGAxdHkA3+pEbaHW ISFyFoEXQH6mTcV1kn9rmBRONw== X-Received: by 2002:a05:6402:558:: with SMTP id i24mr26522920edx.51.1555008547040; Thu, 11 Apr 2019 11:49:07 -0700 (PDT) Received: from localhost.localdomain ([80.233.32.123]) by smtp.gmail.com with ESMTPSA id b10sm1285130edi.28.2019.04.11.11.49.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Apr 2019 11:49:06 -0700 (PDT) From: Tom Murphy To: iommu@lists.linux-foundation.org Cc: dima@arista.com, jamessewart@arista.com, murphyt7@tcd.ie, Tom Murphy , Joerg Roedel , Will Deacon , Robin Murphy , Marek Szyprowski , Kukjin Kim , Krzysztof Kozlowski , Matthias Brugger , Rob Clark , Andy Gross , David Brown , Heiko Stuebner , Thomas Gleixner , Marc Zyngier , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-rockchip@lists.infradead.org Subject: [PATCH 5/9] iommu/amd: Implement .flush_np_cache Date: Thu, 11 Apr 2019 19:47:34 +0100 Message-Id: <20190411184741.27540-6-tmurphy@arista.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190411184741.27540-1-tmurphy@arista.com> References: <20190411184741.27540-1-tmurphy@arista.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Implement flush_np_cache for the AMD iommu driver. This allows the amd iommu non present cache to be flushed if amd_iommu_np_cache is set. Signed-off-by: Tom Murphy --- drivers/iommu/amd_iommu.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c index b319e51c379b..2d4ee10626b4 100644 --- a/drivers/iommu/amd_iommu.c +++ b/drivers/iommu/amd_iommu.c @@ -1319,6 +1319,18 @@ static void domain_flush_devices(struct protection_domain *domain) device_flush_dte(dev_data); } +static void amd_iommu_flush_np_cache(struct iommu_domain *domain, + unsigned long iova, size_t size) +{ + struct protection_domain *dom = to_pdomain(domain); + + if (unlikely(amd_iommu_np_cache)) { + domain_flush_pages(dom, iova, size); + domain_flush_complete(dom); + } +} + + /**************************************************************************** * * The functions below are used the create the page table mappings for @@ -3263,6 +3275,7 @@ const struct iommu_ops amd_iommu_ops = { .flush_iotlb_all = amd_iommu_flush_iotlb_all, .iotlb_range_add = amd_iommu_iotlb_range_add, .iotlb_sync = amd_iommu_flush_iotlb_all, + .flush_np_cache = amd_iommu_flush_np_cache, }; /***************************************************************************** -- 2.17.1