Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1152137pxb; Fri, 20 Nov 2020 02:27:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJzP0Wrspcftm6U+GjjqJKwgym49Fm39dpgdLUQ0yN3LfKOCGo09i58gV7XO0m9+9vGZMW8r X-Received: by 2002:a17:907:411b:: with SMTP id nw19mr31361369ejb.150.1605868057772; Fri, 20 Nov 2020 02:27:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605868057; cv=none; d=google.com; s=arc-20160816; b=ljaMcH3aJnut8uj1EiyMEo2l/R2gKjFHWxTAhFDAxKLe1k1pDGMhluMzyMYUC9kugg RKrSggDJWZnYaMiGuy0kVUPUCXh69j6JpE/q6StRkAlVgCuM9BLXU+7txFAeCtyZuyCb r9V5yhgteeYnwDmIfcZvmZjNff79eyEW1nNELenX45u7cGzq82xY7rI5goP/XdMjlwbb kS0ce7EOiWhNCPZtXLo/fSTD3mjgrFw0XvhMqeZnkUHSBa7X/AQcFqFYRV6Ifo2VLTlg 1pkIbiQKiDshC3+NE3gdi3ngDoy4Ebvl2uZkWB1QGY7ffqFmCInmpn7y4iCACthE6m9t KvoA== 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 :ironport-sdr:ironport-sdr; bh=Mql0VjfWIxUcLmb6iA0Lyjv6KHnwydPK/MCnAviak+E=; b=elHZ7w4MxYR2YnghujMt4kJZT8gQygcjFC3BTN8lo+1Sdnu/+K0KNJ4c9gS7sXPXdt 2An6CsBRR4MVpqVJYBW13KQYG8VjV4qe6hC3VBKK6eKZMIL4AKjLTsb6dy44FA3O+2Xp qZ4ZQwWj2F8UEPFNrJzFKdQPU/eo3b7UlIJA2Kb0UeJTDxnNObLVjw6WWdT7UDGFTiR3 Xxid2ZCVJ8n2D/cJO1COwXTc2/eUbHCkrkLg53Ujf2xT6/fXWykfDjDPezqm3qqVIDmo IDwZgDsCeBGguum4rwWmi7w4qeIuWcqWMHDwU6dswfMm4FsqXtGnPaO0O237bu+/4Vne DckQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id df7si1868416edb.44.2020.11.20.02.27.14; Fri, 20 Nov 2020 02:27:37 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727188AbgKTKYq (ORCPT + 99 others); Fri, 20 Nov 2020 05:24:46 -0500 Received: from mga12.intel.com ([192.55.52.136]:17833 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725797AbgKTKYp (ORCPT ); Fri, 20 Nov 2020 05:24:45 -0500 IronPort-SDR: 7Y1g4UEpnSxIhCfehIOV7aY2KsuiF8kNSkDgPfKM/bcUIy8IJBIG+2c8RF0yVpISn/nM37y+SY vl68hMPU5L/Q== X-IronPort-AV: E=McAfee;i="6000,8403,9810"; a="150717596" X-IronPort-AV: E=Sophos;i="5.78,356,1599548400"; d="scan'208";a="150717596" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Nov 2020 02:24:45 -0800 IronPort-SDR: V47Qm8LF97YdwLW95XLw08tq7lW83B+j1thnH6kTWirbh+BHT6inWN3vCKMXuM5yMMeEj3sgrl A75GFeB0C9cg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.78,356,1599548400"; d="scan'208";a="545393666" Received: from allen-box.sh.intel.com ([10.239.159.28]) by orsmga005.jf.intel.com with ESMTP; 20 Nov 2020 02:24:42 -0800 From: Lu Baolu To: Joerg Roedel , Will Deacon , Tom Murphy , David Woodhouse , Christoph Hellwig Cc: Ashok Raj , Tvrtko Ursulin , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Lu Baolu , Logan Gunthorpe Subject: [PATCH v5 2/7] iommu: Add iommu_dma_free_cpu_cached_iovas() Date: Fri, 20 Nov 2020 18:17:14 +0800 Message-Id: <20201120101719.3172693-3-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201120101719.3172693-1-baolu.lu@linux.intel.com> References: <20201120101719.3172693-1-baolu.lu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tom Murphy Add a iommu_dma_free_cpu_cached_iovas function to allow drivers which use the dma-iommu ops to free cached cpu iovas. Signed-off-by: Tom Murphy Signed-off-by: Lu Baolu Tested-by: Logan Gunthorpe --- drivers/iommu/dma-iommu.c | 9 +++++++++ include/linux/dma-iommu.h | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index 9c827a4d2207..de521e22bafb 100644 --- a/drivers/iommu/dma-iommu.c +++ b/drivers/iommu/dma-iommu.c @@ -49,6 +49,15 @@ struct iommu_dma_cookie { struct iommu_domain *fq_domain; }; +void iommu_dma_free_cpu_cached_iovas(unsigned int cpu, + struct iommu_domain *domain) +{ + struct iommu_dma_cookie *cookie = domain->iova_cookie; + struct iova_domain *iovad = &cookie->iovad; + + free_cpu_cached_iovas(cpu, iovad); +} + static void iommu_dma_entry_dtor(unsigned long data) { struct page *freelist = (struct page *)data; diff --git a/include/linux/dma-iommu.h b/include/linux/dma-iommu.h index 2112f21f73d8..706b68d1359b 100644 --- a/include/linux/dma-iommu.h +++ b/include/linux/dma-iommu.h @@ -37,6 +37,9 @@ void iommu_dma_compose_msi_msg(struct msi_desc *desc, void iommu_dma_get_resv_regions(struct device *dev, struct list_head *list); +void iommu_dma_free_cpu_cached_iovas(unsigned int cpu, + struct iommu_domain *domain); + #else /* CONFIG_IOMMU_DMA */ struct iommu_domain; @@ -78,5 +81,10 @@ static inline void iommu_dma_get_resv_regions(struct device *dev, struct list_he { } +static inline void iommu_dma_free_cpu_cached_iovas(unsigned int cpu, + struct iommu_domain *domain) +{ +} + #endif /* CONFIG_IOMMU_DMA */ #endif /* __DMA_IOMMU_H */ -- 2.25.1