From patchwork Fri Oct 13 14:40:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 10004919 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5852E60360 for ; Fri, 13 Oct 2017 14:41:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4C16F290AD for ; Fri, 13 Oct 2017 14:41:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 40DE2290C6; Fri, 13 Oct 2017 14:41:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B3E70290B3 for ; Fri, 13 Oct 2017 14:41:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758160AbdJMOkT (ORCPT ); Fri, 13 Oct 2017 10:40:19 -0400 Received: from 8bytes.org ([81.169.241.247]:58082 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753394AbdJMOkS (ORCPT ); Fri, 13 Oct 2017 10:40:18 -0400 Received: by theia.8bytes.org (Postfix, from userid 1000) id 74E3CC5; Fri, 13 Oct 2017 16:40:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=8bytes.org; s=mail-1; t=1507905616; bh=aJ9p6HAO5tzrnWKLgbkH0ME8iszp9YKUisc+YLAbTbU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Upic4DfUthVQBM7GWGTxf8CsDOOPtk574tcvqPWl7SUiEDDakZ60L7tkWSaLn1Q38 nORYq7cr5jAQS/qEYYFNZEsoXwEKZUXn99nUBPtsohNUJIFvEmNa5KUdq1YE3v+TVJ 1OQrzQ5PB173e9kLABj6GPDb8ZIO8yWpyq/l8uXeny0AxzYvw0nG1odu1t0a6t+JcF ryZbGhDtK1rEEa8YbgvcS1hQdy0co6aUE/XlAoKuXGhq49HCHXjgQZJk3+42scaaxu vD7D9hCwJBINNoGQduO0XBFFaFTlTv5leGZsW4eB2fF6zcVZz0ORAigi5HTl3nfvGx B723K37bO35DA== From: Joerg Roedel To: iommu@lists.linux-foundation.org, Alex Williamson Cc: Suravee Suthikulpanit , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Joerg Roedel Subject: [PATCH 2/4] iommu/amd: Implement IOMMU-API TLB flush interface Date: Fri, 13 Oct 2017 16:40:11 +0200 Message-Id: <1507905613-30695-3-git-send-email-joro@8bytes.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1507905613-30695-1-git-send-email-joro@8bytes.org> References: <1507905613-30695-1-git-send-email-joro@8bytes.org> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Joerg Roedel Make use of the new IOTLB flush-interface in the IOMMU-API. We don't implement the iotlb_range_add() call-back for now, as this will put too many pressure on the command buffer. Instead, we do a full TLB flush in the iotlb_sync() call-back. Signed-off-by: Joerg Roedel --- drivers/iommu/amd_iommu.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c index 3a702c4..8804264 100644 --- a/drivers/iommu/amd_iommu.c +++ b/drivers/iommu/amd_iommu.c @@ -3032,6 +3032,14 @@ static int amd_iommu_map(struct iommu_domain *dom, unsigned long iova, return ret; } +static void amd_iommu_flush_iotlb_all(struct iommu_domain *dom) +{ + struct protection_domain *domain = to_pdomain(dom); + + domain_flush_tlb_pde(domain); + domain_flush_complete(domain); +} + static size_t amd_iommu_unmap(struct iommu_domain *dom, unsigned long iova, size_t page_size) { @@ -3045,9 +3053,6 @@ static size_t amd_iommu_unmap(struct iommu_domain *dom, unsigned long iova, unmap_size = iommu_unmap_page(domain, iova, page_size); mutex_unlock(&domain->api_lock); - domain_flush_tlb_pde(domain); - domain_flush_complete(domain); - return unmap_size; } @@ -3174,6 +3179,8 @@ const struct iommu_ops amd_iommu_ops = { .map = amd_iommu_map, .unmap = amd_iommu_unmap, .map_sg = default_iommu_map_sg, + .flush_iotlb_all = amd_iommu_flush_iotlb_all, + .iotlb_sync = amd_iommu_flush_iotlb_all, .iova_to_phys = amd_iommu_iova_to_phys, .add_device = amd_iommu_add_device, .remove_device = amd_iommu_remove_device,